summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-07-25 08:20:02 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-07-25 08:23:20 (GMT)
commitbecafaace69980d2980802432e86e7873317a4b6 (patch)
tree09bf0a2a6960d9e2a0ab70fa6493950835c177c5
parent844c3f6fe9d4d2bdc4e76f6a3bf3dfe86ce8c544 (diff)
downloadgit-becafaace69980d2980802432e86e7873317a4b6.zip
git-becafaace69980d2980802432e86e7873317a4b6.tar.gz
git-becafaace69980d2980802432e86e7873317a4b6.tar.bz2
git-gui: Show ref last update times in revision chooser tooltips
If we can we now show the last modification date of a loose ref as part of the tooltip information shown in the revision picker. This gives the user an indication of when was the last time that the ref was modified locally, and may especially be of interest when looking at a tracking branch. If we cannot find the loose ref file than we try to fallback on the reflog and scan it for the date of the last record. We don't start with the reflog however as scanning it backwards from the end is not an easy thing to do in Tcl. So I'm being lazy here and just going through the entire file, line by line. Since that is less efficient than a single stat system call, its our fallback strategy. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--lib/choose_rev.tcl34
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl
index bb6966e..4147b7c 100644
--- a/lib/choose_rev.tcl
+++ b/lib/choose_rev.tcl
@@ -17,6 +17,7 @@ field spec_head ; # list of all head specs
field spec_trck ; # list of all tracking branch specs
field spec_tag ; # list of all tag specs
field tip_data ; # array of tip commit info by refname
+field log_last ; # array of reflog date by refname
field tooltip_wm {} ; # Current tooltip toplevel, if open
field tooltip_t {} ; # Text widget in $tooltip_wm
@@ -518,7 +519,14 @@ method _open_tooltip {} {
set cmit [lindex $data 0]
}
- $tooltip_t insert end "[lindex $spec 0]\n"
+ $tooltip_t insert end [lindex $spec 0]
+ set last [_reflog_last $this [lindex $spec 1]]
+ if {$last ne {}} {
+ $tooltip_t insert end "\n"
+ $tooltip_t insert end "updated"
+ $tooltip_t insert end " $last"
+ }
+ $tooltip_t insert end "\n"
if {$tag ne {}} {
$tooltip_t insert end "\n"
@@ -553,6 +561,30 @@ method _open_tooltip {} {
_position_tooltip $this
}
+method _reflog_last {name} {
+ if {[info exists reflog_last($name)]} {
+ return reflog_last($name)
+ }
+
+ set last {}
+ if {[catch {set last [file mtime [gitdir $name]]}]
+ && ![catch {set g [open [gitdir logs $name] r]}]} {
+ fconfigure $g -translation binary
+ while {[gets $g line] >= 0} {
+ if {[regexp {> ([1-9][0-9]*) } $line line when]} {
+ set last $when
+ }
+ }
+ close $g
+ }
+
+ if {$last ne {}} {
+ set last [clock format $last -format {%a %b %e %H:%M:%S %Y}]
+ }
+ set reflog_last($name) $last
+ return $last
+}
+
method _position_tooltip {} {
set max_h [lindex [split [$tooltip_t index end] .] 0]
set max_w 0