Revision 18a01a0da428c9e1034247e2b40c62e506b73580 authored by Shawn O. Pearce on 20 August 2007, 06:17:05 UTC, committed by Shawn O. Pearce on 20 August 2007, 06:17:05 UTC
Earlier when I rewrote the merge implementation for git-gui I broke
it such that the conflict markers for the "theirs" side of the hunk
was using a full SHA-1 ID in hex, rather than the name of the branch
the user had merged.  This was because I got paranoid and passed off
the full SHA-1 to git-merge, instead of giving it the reference name
the user saw in the merge dialog.

I'd still like to resolve the SHA-1 upfront in git-gui and always use
that value throughout the merge, but I can't do that until we have a
full implementation of git-merge written in Tcl.  Until then its more
important that the conflict markers be useful to the end-user, so we
need to pass off the ref name and not the SHA-1 ID.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent c6951dd
Raw File
status_bar.tcl
# git-gui status bar mega-widget
# Copyright (C) 2007 Shawn Pearce

class status_bar {

field w         ; # our own window path
field w_l       ; # text widget we draw messages into
field w_c       ; # canvas we draw a progress bar into
field status  {}; # single line of text we show
field prefix  {}; # text we format into status
field units   {}; # unit of progress
field meter   {}; # current core git progress meter (if active)

constructor new {path} {
	set w $path
	set w_l $w.l
	set w_c $w.c

	frame $w \
		-borderwidth 1 \
		-relief sunken
	label $w_l \
		-textvariable @status \
		-anchor w \
		-justify left
	pack $w_l -side left

	bind $w <Destroy> [cb _delete %W]
	return $this
}

method start {msg uds} {
	if {[winfo exists $w_c]} {
		$w_c coords bar 0 0 0 20
	} else {
		canvas $w_c \
			-width 100 \
			-height [expr {int([winfo reqheight $w_l] * 0.6)}] \
			-borderwidth 1 \
			-relief groove \
			-highlightt 0
		$w_c create rectangle 0 0 0 20 -tags bar -fill navy
		pack $w_c -side right
	}

	set status $msg
	set prefix $msg
	set units  $uds
	set meter  {}
}

method update {have total} {
	set pdone 0
	if {$total > 0} {
		set pdone [expr {100 * $have / $total}]
	}

	set status [format "%s ... %i of %i %s (%2i%%)" \
		$prefix $have $total $units $pdone]
	$w_c coords bar 0 0 $pdone 20
}

method update_meter {buf} {
	append meter $buf
	set r [string last "\r" $meter]
	if {$r == -1} {
		return
	}

	set prior [string range $meter 0 $r]
	set meter [string range $meter [expr {$r + 1}] end]
	if {[regexp "\\((\\d+)/(\\d+)\\)\\s+done\r\$" $prior _j a b]} {
		update $this $a $b
	}
}

method stop {{msg {}}} {
	destroy $w_c
	if {$msg ne {}} {
		set status $msg
	}
}

method show {msg {test {}}} {
	if {$test eq {} || $status eq $test} {
		set status $msg
	}
}

method _delete {current} {
	if {$current eq $w} {
		delete_this
	}
}

}
back to top