Eskil

Diff
Login

Differences From Artifact [c4279eefb8]:

To Artifact [d1d3a46db7]:


50
51
52
53
54
55
56
57

58
59
60



61
62
63
64
65
66
67
50
51
52
53
54
55
56

57
58


59
60
61
62
63
64
65
66
67
68







-
+

-
-
+
+
+







# eskil::rev::XXX::getPatch {revs {files {}}}
#
# Get a patch of the file tree, between the revisions given.
# revs is in any format understood by this system, and
# should be retrieved from ParseRevs
# An optional list of files that should be included can be given.

# eskil::rev::XXX::commitFile {top filename}
# eskil::rev::XXX::commitFile {top args}
#
# If implemented, enables the commit feature when comparing an edited
# file agains latest check in.
# If implemented, enables the commit feature when comparing edited
# file(s) agains latest check in.
# If no files are given, all edited files are committed.

# eskil::rev::XXX::viewLog {top filename revs}
#
# If implemented, enables the log feature when comparing revisions.
# View log between displayed versions

namespace eval eskil::rev::CVS {}
281
282
283
284
285
286
287
288
289

290
291
292
293
294
295
296
282
283
284
285
286
287
288


289
290
291
292
293
294
295
296







-
-
+







    if {$old != ""} {
        cd $old
    }
}

# Get a SVN patch
proc eskil::rev::SVN::getPatch {revs {files {}}} {
    # TODO: support files
    set cmd [list exec svn diff]
    set cmd [list exec svn diff {*}$files]
    foreach rev $revs {
        lappend cmd -r $rev
    }

    if {[catch {eval $cmd} res]} {
        tk_messageBox -icon error -title "SVN error" -message $res
        return ""
773
774
775
776
777
778
779
780
781









782
783

784
785
786
787
788
789









790
791

792
793
794
795
796
797
798
773
774
775
776
777
778
779


780
781
782
783
784
785
786
787
788
789

790
791
792
793
794


795
796
797
798
799
800
801
802
803
804

805
806
807
808
809
810
811
812







-
-
+
+
+
+
+
+
+
+
+

-
+




-
-
+
+
+
+
+
+
+
+
+

-
+







            lappend result $res
        }
    }
    return $result
}

# Check in CVS controlled file
proc eskil::rev::CVS::commitFile {top filename} {
    set logmsg [LogDialog $top $filename]
proc eskil::rev::CVS::commitFile {top args} {
    if {[llength $args] == 0} {
        set target all
    } elseif {[llength $args] == 1} {
        set target [file tail [lindex $args 0]]
    } else {
        set target "[file tail [lindex $args 0]] ..."
    }        
    set logmsg [LogDialog $top $target]
    if {$logmsg ne ""} {
        catch {exec cvs -q commit -m $logmsg $filename}
        catch {exec cvs -q commit -m $logmsg {*}$args}
    }
}

# Check in SVN controlled file
proc eskil::rev::SVN::commitFile {top filename} {
    set logmsg [LogDialog $top $filename]
proc eskil::rev::SVN::commitFile {top args} {
    if {[llength $args] == 0} {
        set target all
    } elseif {[llength $args] == 1} {
        set target [file tail [lindex $args 0]]
    } else {
        set target "[file tail [lindex $args 0]] ..."
    }        
    set logmsg [LogDialog $top $target]
    if {$logmsg ne ""} {
        catch {exec svn -q commit -m $logmsg $filename}
        catch {exec svn -q commit -m $logmsg {*}$args}
    }
}

# View log between displayed versions
proc eskil::rev::CVS::viewLog {top filename revs} {
    set cmd [list exec cvs -q log -N]
    if {[llength $revs] > 1} {
879
880
881
882
883
884
885
886

887
888
889
890
891
892
893
893
894
895
896
897
898
899

900
901
902
903
904
905
906
907







-
+







    set ::diff($top,rightFile) $file
    set ::diff($top,rightOK) 1
    set ::diff($top,leftLabel) $rev
    set ::diff($top,leftOK) 0
    set ::Pref(toolbar) 1
}

# Prepare for RCS/CVS/CT diff. Checkout copies of the versions needed.
# Prepare for revision diff. Checkout copies of the versions needed.
proc prepareRev {top} {
    global Pref

    $::widgets($top,commit) configure -state disabled
    $::widgets($top,log)    configure -state disabled

    set type $::diff($top,modetype)
950
951
952
953
954
955
956
957

958
959
960
961
962
963
964
965
966
967
968





969

970
971
972
973
974
975
976
977
978
979
980
981



982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000






1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021

1022
1023
1024
1025

1026
1027
1028
1029
1030
1031
1032
964
965
966
967
968
969
970

971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987

988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048

1049
1050
1051
1052

1053
1054
1055
1056
1057
1058
1059
1060







-
+











+
+
+
+
+
-
+












+
+
+



















+
+
+
+
+
+




















-
+



-
+







            $::widgets($top,log) configure -state normal
        }
    }
    # Make sure labels are updated before processing starts
    update idletasks
}

# Clean up after a RCS/CVS/CT diff.
# Clean up after a revision diff.
proc cleanupRev {top} {
    global Pref

    clearTmp $::diff($top,rightFile) $::diff($top,leftFile)
    set ::diff($top,rightFile) $::diff($top,RevFile)
    set ::diff($top,leftFile) $::diff($top,RevFile)
}

proc revCommit {top} {
    if {[$::widgets($top,commit) cget -state] eq "disabled"} return
    set type $::diff($top,modetype)
    if {$::diff($top,mode) eq "patch"} {
        set files $::diff($top,reviewFiles)
    } else {
        set files [list $::diff($top,RevFile)]
    }
    eskil::rev::${type}::commitFile $top $::diff($top,RevFile)
    eskil::rev::${type}::commitFile $top {*}$files
}

proc revLog {top} {
    if {[$::widgets($top,log) cget -state] eq "disabled"} return
    set type $::diff($top,modetype)
    eskil::rev::${type}::viewLog $top $::diff($top,RevFile) \
            $::diff($top,RevRevs)
}

# Get a complete tree patch from this system.
proc getFullPatch {top} {
    global Pref

    $::widgets($top,commit) configure -state disabled
    $::widgets($top,log)    configure -state disabled

    set type $::diff($top,modetype)
    set files $::diff($top,reviewFiles)

    set revs {}

    # Search for revision options
    if {$::diff($top,doptrev1) != ""} {
        lappend revs $::diff($top,doptrev1)
    }
    if {$::diff($top,doptrev2) != ""} {
        lappend revs $::diff($top,doptrev2)
    }

    set revs [eskil::rev::${type}::ParseRevs "" $revs]
    set revlabels {}
    foreach rev $revs {
        lappend revlabels [GetLastTwoPath $rev]
    }

    if {[llength $revs] == 0} {
        if {[info commands eskil::rev::${type}::commitFile] ne ""} {
            $::widgets($top,commit) configure -state normal
        }
    }

    return [eskil::rev::${type}::getPatch $revs $files]
}

##############################################################################
# Utilities
##############################################################################

# Get the last two elements in a file path
proc GetLastTwoPath {path} {
    set last [file tail $path]
    set penultimate [file tail [file dirname $path]]
    if {$penultimate eq "."} {
        return $last
    } else {
        return [file join $penultimate $last]
    }
}

# Dialog for log message
proc LogDialog {top filename {clean 0}} {
proc LogDialog {top target {clean 0}} {
    set w $top.logmsg
    destroy  $w
    toplevel $w -padx 3 -pady 3
    wm title $w "Commit log message for [file tail $filename]"
    wm title $w "Commit log message for $target"

    set ::diff($top,logdialogok) 0

    text $w.t -width 70 -height 10
    if {!$clean && [info exists ::diff(logdialog)]} {
        $w.t insert end $::diff(logdialog)
        $w.t tag add sel 1.0 end-1c