contrib/hgk
changeset 1278 6a0d373d3126
parent 1240 cc756ffd4d04
child 1308 2073e5a71008
equal deleted inserted replaced
1277:0bf11906df28 1278:6a0d373d3126
    32     set startmsecs [clock clicks -milliseconds]
    32     set startmsecs [clock clicks -milliseconds]
    33     set nextupdate [expr $startmsecs + 100]
    33     set nextupdate [expr $startmsecs + 100]
    34     set ncmupdate 1
    34     set ncmupdate 1
    35     if [catch {
    35     if [catch {
    36 	set parse_args [concat --default HEAD $rargs]
    36 	set parse_args [concat --default HEAD $rargs]
    37 	set parsed_args [split [eval exec hg git-rev-parse $parse_args] "\n"]
    37 	set parsed_args [split [eval exec hg debug-rev-parse $parse_args] "\n"]
    38     }] {
    38     }] {
    39 	# if git-rev-parse failed for some reason...
    39 	# if git-rev-parse failed for some reason...
    40 	if {$rargs == {}} {
    40 	if {$rargs == {}} {
    41 	    set rargs HEAD
    41 	    set rargs HEAD
    42 	}
    42 	}
    43 	set parsed_args $rargs
    43 	set parsed_args $rargs
    44     }
    44     }
    45     if [catch {
    45     if [catch {
    46 	set commfd [open "|hg git-rev-list --header --topo-order --parents $parsed_args" r]
    46 	set commfd [open "|hg debug-rev-list --header --topo-order --parents $parsed_args" r]
    47     } err] {
    47     } err] {
    48 	puts stderr "Error executing hg git-rev-list: $err"
    48 	puts stderr "Error executing hg debug-rev-list: $err"
    49 	exit 1
    49 	exit 1
    50     }
    50     }
    51     set leftover {}
    51     set leftover {}
    52     fconfigure $commfd -blocking 0 -translation lf
    52     fconfigure $commfd -blocking 0 -translation lf
    53     fileevent $commfd readable [list getcommitlines $commfd]
    53     fileevent $commfd readable [list getcommitlines $commfd]
   111 	if {!$ok} {
   111 	if {!$ok} {
   112 	    set shortcmit $cmit
   112 	    set shortcmit $cmit
   113 	    if {[string length $shortcmit] > 80} {
   113 	    if {[string length $shortcmit] > 80} {
   114 		set shortcmit "[string range $shortcmit 0 80]..."
   114 		set shortcmit "[string range $shortcmit 0 80]..."
   115 	    }
   115 	    }
   116 	    error_popup "Can't parse hg git-rev-list output: {$shortcmit}"
   116 	    error_popup "Can't parse hg debug-rev-list output: {$shortcmit}"
   117 	    exit 1
   117 	    exit 1
   118 	}
   118 	}
   119 	set id [lindex $ids 0]
   119 	set id [lindex $ids 0]
   120 	set olds [lrange $ids 1 end]
   120 	set olds [lrange $ids 1 end]
   121 	set cmit [string range $cmit [expr {$j + 1}] end]
   121 	set cmit [string range $cmit [expr {$j + 1}] end]
   162 	fileevent $commfd readable [list getcommitlines $commfd]
   162 	fileevent $commfd readable [list getcommitlines $commfd]
   163     }
   163     }
   164 }
   164 }
   165 
   165 
   166 proc readcommit {id} {
   166 proc readcommit {id} {
   167     if [catch {set contents [exec hg git-cat-file commit $id]}] return
   167     if [catch {set contents [exec hg debug-cat-file commit $id]}] return
   168     parsecommit $id $contents 0 {}
   168     parsecommit $id $contents 0 {}
   169 }
   169 }
   170 
   170 
   171 proc parsecommit {id contents listed olds} {
   171 proc parsecommit {id contents listed olds} {
   172     global commitinfo children nchildren parents nparents cdate ncleft
   172     global commitinfo children nchildren parents nparents cdate ncleft
  1706 	}
  1706 	}
  1707 	append inputids $lineid($l) "\n"
  1707 	append inputids $lineid($l) "\n"
  1708     }
  1708     }
  1709 
  1709 
  1710     if {[catch {
  1710     if {[catch {
  1711 	set f [open [list | hg git-diff-tree --stdin -s -r -S$findstring \
  1711 	set f [open [list | hg debug-diff-tree --stdin -s -r -S$findstring \
  1712 			 << $inputids] r]
  1712 			 << $inputids] r]
  1713     } err]} {
  1713     } err]} {
  1714 	error_popup "Error starting search process: $err"
  1714 	error_popup "Error starting search process: $err"
  1715 	return
  1715 	return
  1716     }
  1716     }
  1809     }
  1809     }
  1810 
  1810 
  1811     # start off a git-diff-tree process if needed
  1811     # start off a git-diff-tree process if needed
  1812     if {$diffsneeded ne {}} {
  1812     if {$diffsneeded ne {}} {
  1813 	if {[catch {
  1813 	if {[catch {
  1814 	    set df [open [list | hg git-diff-tree -r --stdin << $diffsneeded] r]
  1814 	    set df [open [list | hg debug-diff-tree -r --stdin << $diffsneeded] r]
  1815 	} err ]} {
  1815 	} err ]} {
  1816 	    error_popup "Error starting search process: $err"
  1816 	    error_popup "Error starting search process: $err"
  1817 	    return
  1817 	    return
  1818 	}
  1818 	}
  1819 	catch {unset fdiffids}
  1819 	catch {unset fdiffids}
  1841 	if {[eof $df]} {
  1841 	if {[eof $df]} {
  1842 	    donefilediff
  1842 	    donefilediff
  1843 	    if {[catch {close $df} err]} {
  1843 	    if {[catch {close $df} err]} {
  1844 		stopfindproc
  1844 		stopfindproc
  1845 		bell
  1845 		bell
  1846 		error_popup "Error in hg git-diff-tree: $err"
  1846 		error_popup "Error in hg debug-diff-tree: $err"
  1847 	    } elseif {[info exists findids]} {
  1847 	    } elseif {[info exists findids]} {
  1848 		set ids $findids
  1848 		set ids $findids
  1849 		stopfindproc
  1849 		stopfindproc
  1850 		bell
  1850 		bell
  1851 		error_popup "Couldn't find diffs for {$ids}"
  1851 		error_popup "Couldn't find diffs for {$ids}"
  2230     foreach id $ids {
  2230     foreach id $ids {
  2231 	if {$gca eq {}} {
  2231 	if {$gca eq {}} {
  2232 	    set gca $id
  2232 	    set gca $id
  2233 	} else {
  2233 	} else {
  2234 	    if {[catch {
  2234 	    if {[catch {
  2235 		set gca [exec hg git-merge-base $gca $id]
  2235 		set gca [exec hg debug-merge-base $gca $id]
  2236 	    } err]} {
  2236 	    } err]} {
  2237 		return {}
  2237 		return {}
  2238 	    }
  2238 	    }
  2239 	}
  2239 	}
  2240     }
  2240     }
  2318     catch {unset filelines}
  2318     catch {unset filelines}
  2319     catch {unset groupfilenum}
  2319     catch {unset groupfilenum}
  2320     catch {unset grouphunks}
  2320     catch {unset grouphunks}
  2321     set groupfilelast -1
  2321     set groupfilelast -1
  2322     foreach p $parents($diffmergeid) {
  2322     foreach p $parents($diffmergeid) {
  2323 	set cmd [list | hg git-diff-tree -p $p $diffmergeid]
  2323 	set cmd [list | hg debug-diff-tree -p $p $diffmergeid]
  2324 	set cmd [concat $cmd $mergefilelist($diffmergeid)]
  2324 	set cmd [concat $cmd $mergefilelist($diffmergeid)]
  2325 	if {[catch {set f [open $cmd r]} err]} {
  2325 	if {[catch {set f [open $cmd r]} err]} {
  2326 	    error_popup "Error getting diffs: $err"
  2326 	    error_popup "Error getting diffs: $err"
  2327 	    foreach f $flist {
  2327 	    foreach f $flist {
  2328 		catch {close $f}
  2328 		catch {close $f}
  2762     global treediff parents treepending
  2762     global treediff parents treepending
  2763     set treepending $ids
  2763     set treepending $ids
  2764     set treediff {}
  2764     set treediff {}
  2765     set id [lindex $ids 0]
  2765     set id [lindex $ids 0]
  2766     set p [lindex $ids 1]
  2766     set p [lindex $ids 1]
  2767     if [catch {set gdtf [open "|hg git-diff-tree -r $p $id" r]}] return
  2767     if [catch {set gdtf [open "|hg debug-diff-tree -r $p $id" r]}] return
  2768     fconfigure $gdtf -blocking 0
  2768     fconfigure $gdtf -blocking 0
  2769     fileevent $gdtf readable [list gettreediffline $gdtf $ids]
  2769     fileevent $gdtf readable [list gettreediffline $gdtf $ids]
  2770 }
  2770 }
  2771 
  2771 
  2772 proc gettreediffline {gdtf ids} {
  2772 proc gettreediffline {gdtf ids} {
  2798     global difffilestart nextupdate diffinhdr treediffs
  2798     global difffilestart nextupdate diffinhdr treediffs
  2799 
  2799 
  2800     set id [lindex $ids 0]
  2800     set id [lindex $ids 0]
  2801     set p [lindex $ids 1]
  2801     set p [lindex $ids 1]
  2802     set env(GIT_DIFF_OPTS) $diffopts
  2802     set env(GIT_DIFF_OPTS) $diffopts
  2803     set cmd [list | hg git-diff-tree -r -p -C $p $id]
  2803     set cmd [list | hg debug-diff-tree -r -p -C $p $id]
  2804     if {[catch {set bdf [open $cmd r]} err]} {
  2804     if {[catch {set bdf [open $cmd r]} err]} {
  2805 	puts "error getting diffs: $err"
  2805 	puts "error getting diffs: $err"
  2806 	return
  2806 	return
  2807     }
  2807     }
  2808     set diffinhdr 0
  2808     set diffinhdr 0
  3385     global patchtop
  3385     global patchtop
  3386 
  3386 
  3387     set oldid [$patchtop.fromsha1 get]
  3387     set oldid [$patchtop.fromsha1 get]
  3388     set newid [$patchtop.tosha1 get]
  3388     set newid [$patchtop.tosha1 get]
  3389     set fname [$patchtop.fname get]
  3389     set fname [$patchtop.fname get]
  3390     if {[catch {exec hg git-diff-tree -p $oldid $newid >$fname &} err]} {
  3390     if {[catch {exec hg debug-diff-tree -p $oldid $newid >$fname &} err]} {
  3391 	error_popup "Error creating patch: $err"
  3391 	error_popup "Error creating patch: $err"
  3392     }
  3392     }
  3393     catch {destroy $patchtop}
  3393     catch {destroy $patchtop}
  3394     unset patchtop
  3394     unset patchtop
  3395 }
  3395 }
  3606 
  3606 
  3607 # defaults...
  3607 # defaults...
  3608 set datemode 0
  3608 set datemode 0
  3609 set boldnames 0
  3609 set boldnames 0
  3610 set diffopts "-U 5 -p"
  3610 set diffopts "-U 5 -p"
  3611 set wrcomcmd "hg git-diff-tree --stdin -p --pretty"
  3611 set wrcomcmd "hg debug-diff-tree --stdin -p --pretty"
  3612 
  3612 
  3613 set mainfont {Helvetica 9}
  3613 set mainfont {Helvetica 9}
  3614 set textfont {Courier 9}
  3614 set textfont {Courier 9}
  3615 set findmergefiles 0
  3615 set findmergefiles 0
  3616 set gaudydiff 0
  3616 set gaudydiff 0