* [PATCH] gitk: add Update menu item.
@ 2005-09-20 12:24 Sven Verdoolaege
2005-09-20 14:56 ` Sven Verdoolaege
2005-09-21 23:46 ` Paul Mackerras
0 siblings, 2 replies; 9+ messages in thread
From: Sven Verdoolaege @ 2005-09-20 12:24 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
Update will redraw the commits if any commits have been added to any
of the selected heads. The new commits appear on the top.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
gitk | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 73 insertions(+), 18 deletions(-)
7f319aaadb801da3bccd7b78d372f03e09575b47
diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -16,8 +16,22 @@ proc gitdir {} {
}
}
+proc parse_args {rargs} {
+ if [catch {
+ set parse_args [concat --default HEAD $rargs]
+ set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
+ }] {
+ # if git-rev-parse failed for some reason...
+ if {$rargs == {}} {
+ set rargs HEAD
+ }
+ set parsed_args $rargs
+ }
+ return $parsed_args
+}
+
proc getcommits {rargs} {
- global commits commfd phase canv mainfont env
+ global oldcommits commits commfd phase canv mainfont env
global startmsecs nextupdate ncmupdate
global ctext maincursor textcursor leftover
@@ -27,21 +41,13 @@ proc getcommits {rargs} {
error_popup "Cannot find the git directory \"$gitdir\"."
exit 1
}
+ set oldcommits {}
set commits {}
set phase getcommits
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100]
set ncmupdate 1
- if [catch {
- set parse_args [concat --default HEAD $rargs]
- set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
- }] {
- # if git-rev-parse failed for some reason...
- if {$rargs == {}} {
- set rargs HEAD
- }
- set parsed_args $rargs
- }
+ set parsed_args [parse_args $rargs]
if [catch {
set commfd [open "|git-rev-list --header --topo-order --parents $parsed_args" r]
} err] {
@@ -59,7 +65,7 @@ proc getcommits {rargs} {
}
proc getcommitlines {commfd} {
- global commits parents cdate children
+ global oldcommits commits parents cdate children
global commitlisted phase commitinfo nextupdate
global stopped redisplaying leftover
@@ -119,6 +125,11 @@ to allow selection of commits to be disp
set id [lindex $ids 0]
set olds [lrange $ids 1 end]
set cmit [string range $cmit [expr {$j + 1}] end]
+ if {$phase == "updatecommits"} {
+ set oldcommits $commits
+ set commits {}
+ set phase getcommits
+ }
lappend commits $id
set commitlisted($id) 1
parsecommit $id $cmit 1 [lrange $ids 1 end]
@@ -324,7 +335,7 @@ proc error_popup msg {
tkwait window $w
}
-proc makewindow {} {
+proc makewindow {rargs} {
global canv canv2 canv3 linespc charspc ctext cflist textfont
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
@@ -334,6 +345,7 @@ proc makewindow {} {
menu .bar
.bar add cascade -label "File" -menu .bar.file
menu .bar.file
+ .bar.file add command -label "Update" -command "updatecommits [list $rargs]"
.bar.file add command -label "Reread references" -command rereadrefs
.bar.file add command -label "Quit" -command doquit
menu .bar.help
@@ -1470,16 +1482,22 @@ proc drawcommit {id} {
}
proc finishcommits {} {
- global phase
+ global phase oldcommits
global canv mainfont ctext maincursor textcursor
- if {$phase != "incrdraw"} {
+ if {$phase == "incrdraw"} {
+ foreach id $oldcommits {
+ drawcommit $id
+ }
+ set oldcommits {}
+ drawrest
+ } elseif {$phase == "updatecommits"} {
+ set phase {}
+ } else {
$canv delete all
$canv create text 3 3 -anchor nw -text "No commits selected" \
-font $mainfont -tags textitems
set phase {}
- } else {
- drawrest
}
. config -cursor $maincursor
settextcursor $textcursor
@@ -3617,6 +3635,43 @@ proc rereadrefs {} {
}
}
+proc updatecommits {rargs} {
+ global phase
+ global startmsecs nextupdate ncmupdate
+ global idtags idheads idotherrefs
+ global leftover
+
+ set refids [concat [array names idtags] \
+ [array names idheads] [array names idotherrefs]]
+ foreach id $refids {
+ if {[info exists ref($id)]} continue
+ set ref($id) $id
+ lappend ignore "^$id"
+ }
+ set parsed_args {}
+ foreach a [parse_args $rargs] {
+ if {![info exists ref($a)]} {
+ lappend parsed_args $a
+ }
+ }
+ rereadrefs
+ if [catch {
+ set commfd [open "|git-rev-list --header --topo-order --parents $parsed_args $ignore" r]
+ } err] {
+ puts stderr "Error executing git-rev-list: $err"
+ exit 1
+ }
+ set phase updatecommits
+ set startmsecs [clock clicks -milliseconds]
+ set nextupdate [expr $startmsecs + 100]
+ set ncmupdate 1
+ set leftover {}
+ fconfigure $commfd -blocking 0 -translation lf
+ fileevent $commfd readable [list getcommitlines $commfd]
+ . config -cursor watch
+ settextcursor watch
+}
+
proc showtag {tag isnew} {
global ctext cflist tagcontents tagids linknum
@@ -3684,6 +3739,6 @@ set redisplaying 0
set stuffsaved 0
set patchnum 0
setcoords
-makewindow
+makewindow $revtreeargs
readrefs
getcommits $revtreeargs
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] gitk: add Update menu item.
2005-09-20 12:24 [PATCH] gitk: add Update menu item Sven Verdoolaege
@ 2005-09-20 14:56 ` Sven Verdoolaege
2005-09-21 23:46 ` Paul Mackerras
1 sibling, 0 replies; 9+ messages in thread
From: Sven Verdoolaege @ 2005-09-20 14:56 UTC (permalink / raw)
To: Paul Mackerras, git
On Tue, Sep 20, 2005 at 02:24:23PM +0200, Sven Verdoolaege wrote:
> Update will redraw the commits if any commits have been added to any
> of the selected heads. The new commits appear on the top.
>
It appears I sent this patch to soon.
With the additional patch below, it seems to work,
that is, it survives a rebase.
I can send a replacement patch combining the two patches if
anyone is interested.
skimo
diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -68,6 +68,7 @@ proc getcommitlines {commfd} {
global oldcommits commits parents cdate children
global commitlisted phase commitinfo nextupdate
global stopped redisplaying leftover
+ global canv
set stuff [read $commfd]
if {$stuff == {}} {
@@ -126,6 +127,7 @@ to allow selection of commits to be disp
set olds [lrange $ids 1 end]
set cmit [string range $cmit [expr {$j + 1}] end]
if {$phase == "updatecommits"} {
+ $canv delete all
set oldcommits $commits
set commits {}
set phase getcommits
@@ -133,7 +135,7 @@ to allow selection of commits to be disp
lappend commits $id
set commitlisted($id) 1
parsecommit $id $cmit 1 [lrange $ids 1 end]
- drawcommit $id
+ drawcommit $id 1
if {[clock clicks -milliseconds] >= $nextupdate} {
doupdate 1
}
@@ -143,7 +145,7 @@ to allow selection of commits to be disp
set stopped 0
set phase "getcommits"
foreach id $commits {
- drawcommit $id
+ drawcommit $id 1
if {$stopped} break
if {[clock clicks -milliseconds] >= $nextupdate} {
doupdate 1
@@ -1449,7 +1451,7 @@ proc decidenext {{noread 0}} {
return $level
}
-proc drawcommit {id} {
+proc drawcommit {id reading} {
global phase todo nchildren datemode nextupdate
global numcommits ncmupdate displayorder todo onscreen
@@ -1478,7 +1480,7 @@ proc drawcommit {id} {
break
}
}
- drawmore 1
+ drawmore $reading
}
proc finishcommits {} {
@@ -1487,7 +1489,7 @@ proc finishcommits {} {
if {$phase == "incrdraw"} {
foreach id $oldcommits {
- drawcommit $id
+ drawcommit $id 0
}
set oldcommits {}
drawrest
@@ -3636,7 +3638,7 @@ proc rereadrefs {} {
}
proc updatecommits {rargs} {
- global phase
+ global commfd phase
global startmsecs nextupdate ncmupdate
global idtags idheads idotherrefs
global leftover
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] gitk: add Update menu item.
2005-09-20 12:24 [PATCH] gitk: add Update menu item Sven Verdoolaege
2005-09-20 14:56 ` Sven Verdoolaege
@ 2005-09-21 23:46 ` Paul Mackerras
2005-09-22 13:30 ` Sven Verdoolaege
1 sibling, 1 reply; 9+ messages in thread
From: Paul Mackerras @ 2005-09-21 23:46 UTC (permalink / raw)
To: Sven Verdoolaege; +Cc: git
Sven Verdoolaege writes:
> Update will redraw the commits if any commits have been added to any
> of the selected heads. The new commits appear on the top.
I like the idea but I am not sure if you have implemented it the best
way.
Are we sure that all the commits we had before doing the update will
still be there after the update? What if I had checked in some
changes and run gitk, and then decided that the commit I just created
was wrong, and so I set HEAD to HEAD^1 and did a git prune, then told
gitk to update - shouldn't I see the top commit disappear?
Maybe it would be better to just clean out everything and re-read all
the commits from scratch.
Also, I'm not convinced that doing ^$id for all tags, heads and other
refs is correct. Although we have read the reference and know the ID,
that doesn't mean we have seen that commit and displayed it.
The more general problem is to provide a way for the user to change
the set of commits displayed using a dialog box. That would require
gitk to understand its command-line arguments so that the elements of
the dialog box could be initialized properly, though.
Some other comments:
> + .bar.file add command -label "Update" -command "updatecommits [list $rargs]"
This would be better as:
.bar.file add command -label "Update" -command [list updatecommits $rargs]
> + rereadrefs
We don't need the redrawing part of rereadrefs, just the bit that
unsets tagids etc. and calls readrefs.
Regards,
Paul.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] gitk: add Update menu item.
2005-09-21 23:46 ` Paul Mackerras
@ 2005-09-22 13:30 ` Sven Verdoolaege
0 siblings, 0 replies; 9+ messages in thread
From: Sven Verdoolaege @ 2005-09-22 13:30 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
On Thu, Sep 22, 2005 at 09:46:43AM +1000, Paul Mackerras wrote:
> Also, I'm not convinced that doing ^$id for all tags, heads and other
> refs is correct. Although we have read the reference and know the ID,
> that doesn't mean we have seen that commit and displayed it.
You're right. I typically use "--all", but obviously you don't have to.
> The more general problem is to provide a way for the user to change
> the set of commits displayed using a dialog box. That would require
> gitk to understand its command-line arguments so that the elements of
> the dialog box could be initialized properly, though.
I'll leave that to you.
The patch below should address your other concerns.
Btw, are you still maintaining dirdiff ?
I really like it, but apparently I'm the only one on this list.
skimo
--
gitk: add Update menu item.
Update will redraw the commits if any commits have been added to any
of the selected heads. The new commits appear on the top.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
commit c9b43cd506daf3884cf3ea8ef4fb75f4d010ddc7
tree c838aa39f51a05c1de8da7a0fd648a78b425b38b
parent acfadcfb48e34fdc441e9cffbb385fce9693b363
author Sven Verdoolaege <skimo@kotnet.org> Thu, 22 Sep 2005 15:27:19 +0200
committer Sven Verdoolaege <skimo@kotnet.org> Thu, 22 Sep 2005 15:27:19 +0200
gitk | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 141 insertions(+), 34 deletions(-)
diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -16,8 +16,24 @@ proc gitdir {} {
}
}
+proc parse_args {rargs} {
+ global parsed_args
+
+ if [catch {
+ set parse_args [concat --default HEAD $rargs]
+ set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
+ }] {
+ # if git-rev-parse failed for some reason...
+ if {$rargs == {}} {
+ set rargs HEAD
+ }
+ set parsed_args $rargs
+ }
+ return $parsed_args
+}
+
proc getcommits {rargs} {
- global commits commfd phase canv mainfont env
+ global oldcommits commits commfd phase canv mainfont env
global startmsecs nextupdate ncmupdate
global ctext maincursor textcursor leftover
@@ -27,21 +43,13 @@ proc getcommits {rargs} {
error_popup "Cannot find the git directory \"$gitdir\"."
exit 1
}
+ set oldcommits {}
set commits {}
set phase getcommits
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100]
set ncmupdate 1
- if [catch {
- set parse_args [concat --default HEAD $rargs]
- set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
- }] {
- # if git-rev-parse failed for some reason...
- if {$rargs == {}} {
- set rargs HEAD
- }
- set parsed_args $rargs
- }
+ set parsed_args [parse_args $rargs]
if [catch {
set commfd [open "|git-rev-list --header --topo-order --parents $parsed_args" r]
} err] {
@@ -59,9 +67,10 @@ proc getcommits {rargs} {
}
proc getcommitlines {commfd} {
- global commits parents cdate children
+ global oldcommits commits parents cdate children nchildren
global commitlisted phase commitinfo nextupdate
global stopped redisplaying leftover
+ global canv
set stuff [read $commfd]
if {$stuff == {}} {
@@ -119,10 +128,18 @@ to allow selection of commits to be disp
set id [lindex $ids 0]
set olds [lrange $ids 1 end]
set cmit [string range $cmit [expr {$j + 1}] end]
+ if {$phase == "updatecommits"} {
+ $canv delete all
+ set oldcommits $commits
+ set commits {}
+ unset children
+ unset nchildren
+ set phase getcommits
+ }
lappend commits $id
set commitlisted($id) 1
parsecommit $id $cmit 1 [lrange $ids 1 end]
- drawcommit $id
+ drawcommit $id 1
if {[clock clicks -milliseconds] >= $nextupdate} {
doupdate 1
}
@@ -132,7 +149,7 @@ to allow selection of commits to be disp
set stopped 0
set phase "getcommits"
foreach id $commits {
- drawcommit $id
+ drawcommit $id 1
if {$stopped} break
if {[clock clicks -milliseconds] >= $nextupdate} {
doupdate 1
@@ -168,16 +185,9 @@ proc readcommit {id} {
parsecommit $id $contents 0 {}
}
-proc parsecommit {id contents listed olds} {
- global commitinfo children nchildren parents nparents cdate ncleft
+proc updatechildren {id olds} {
+ global children nchildren parents nparents ncleft
- set inhdr 1
- set comment {}
- set headline {}
- set auname {}
- set audate {}
- set comname {}
- set comdate {}
if {![info exists nchildren($id)]} {
set children($id) {}
set nchildren($id) 0
@@ -196,6 +206,19 @@ proc parsecommit {id contents listed old
incr ncleft($p)
}
}
+}
+
+proc parsecommit {id contents listed olds} {
+ global commitinfo cdate
+
+ set inhdr 1
+ set comment {}
+ set headline {}
+ set auname {}
+ set audate {}
+ set comname {}
+ set comdate {}
+ updatechildren $id $olds
foreach line [split $contents "\n"] {
if {$inhdr} {
if {$line == {}} {
@@ -240,6 +263,9 @@ proc parsecommit {id contents listed old
proc readrefs {} {
global tagids idtags headids idheads tagcontents
+ foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
+ catch {unset $v}
+ }
set tags [glob -nocomplain -types f [gitdir]/refs/tags/*]
foreach f $tags {
catch {
@@ -324,7 +350,7 @@ proc error_popup msg {
tkwait window $w
}
-proc makewindow {} {
+proc makewindow {rargs} {
global canv canv2 canv3 linespc charspc ctext cflist textfont
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
@@ -334,6 +360,7 @@ proc makewindow {} {
menu .bar
.bar add cascade -label "File" -menu .bar.file
menu .bar.file
+ .bar.file add command -label "Update" -command [list updatecommits $rargs]
.bar.file add command -label "Reread references" -command rereadrefs
.bar.file add command -label "Quit" -command doquit
menu .bar.help
@@ -1437,7 +1464,7 @@ proc decidenext {{noread 0}} {
return $level
}
-proc drawcommit {id} {
+proc drawcommit {id reading} {
global phase todo nchildren datemode nextupdate
global numcommits ncmupdate displayorder todo onscreen
@@ -1466,20 +1493,29 @@ proc drawcommit {id} {
break
}
}
- drawmore 1
+ drawmore $reading
}
proc finishcommits {} {
- global phase
+ global phase oldcommits commits
global canv mainfont ctext maincursor textcursor
+ global parents
- if {$phase != "incrdraw"} {
+ if {$phase == "incrdraw" || $phase == "removecommits"} {
+ foreach id $oldcommits {
+ lappend commits $id
+ updatechildren $id $parents($id)
+ drawcommit $id 0
+ }
+ set oldcommits {}
+ drawrest
+ } elseif {$phase == "updatecommits"} {
+ set phase {}
+ } else {
$canv delete all
$canv create text 3 3 -anchor nw -text "No commits selected" \
-font $mainfont -tags textitems
set phase {}
- } else {
- drawrest
}
. config -cursor $maincursor
settextcursor $textcursor
@@ -3603,9 +3639,6 @@ proc rereadrefs {} {
set ref($id) [listrefs $id]
}
}
- foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
- catch {unset $v}
- }
readrefs
set refids [lsort -unique [concat $refids [array names idtags] \
[array names idheads] [array names idotherrefs]]]
@@ -3617,6 +3650,80 @@ proc rereadrefs {} {
}
}
+proc updatecommits {rargs} {
+ global commitlisted commfd phase
+ global startmsecs nextupdate ncmupdate
+ global idtags idheads idotherrefs
+ global leftover
+ global parsed_args
+ global canv
+ global oldcommits commits
+ global parents nchildren children ncleft
+
+ set old_args $parsed_args
+ parse_args $rargs
+
+ foreach id $old_args {
+ if {![regexp {^[0-9a-f]{40}$} $id]} continue
+ if {[info exists oldref($id)]} continue
+ set oldref($id) $id
+ lappend ignoreold "^$id"
+ }
+ foreach id $parsed_args {
+ if {![regexp {^[0-9a-f]{40}$} $id]} continue
+ if {[info exists ref($id)]} continue
+ set ref($id) $id
+ lappend ignorenew "^$id"
+ }
+
+ foreach a $old_args {
+ if {![info exists ref($a)]} {
+ lappend ignorenew $a
+ }
+ }
+
+ set phase updatecommits
+ set removed_commits [split [eval exec git-rev-list $ignorenew] "\n" ]
+ if {[llength $removed_commits] > 0} {
+ $canv delete all
+ set oldcommits {}
+ foreach c $commits {
+ if {[lsearch $c $removed_commits] < 0} {
+ lappend oldcommits $c
+ } else {
+ unset commitlisted($c)
+ }
+ }
+ set commits {}
+ unset children
+ unset nchildren
+ set phase removecommits
+ }
+
+ set args {}
+ foreach a $parsed_args {
+ if {![info exists oldref($a)]} {
+ lappend args $a
+ }
+ }
+
+ readrefs
+ if [catch {
+ set commfd [open "|git-rev-list --header --topo-order --parents $args $ignoreold" r]
+ } err] {
+ puts stderr "Error executing git-rev-list: $err"
+ exit 1
+ }
+ set startmsecs [clock clicks -milliseconds]
+ set nextupdate [expr $startmsecs + 100]
+ set ncmupdate 1
+ set leftover {}
+ fconfigure $commfd -blocking 0 -translation lf
+ fileevent $commfd readable [list getcommitlines $commfd]
+ . config -cursor watch
+ settextcursor watch
+}
+
proc showtag {tag isnew} {
global ctext cflist tagcontents tagids linknum
@@ -3684,6 +3791,6 @@ set redisplaying 0
set stuffsaved 0
set patchnum 0
setcoords
-makewindow
+makewindow $revtreeargs
readrefs
getcommits $revtreeargs
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] gitk: add Update menu item.
@ 2005-11-23 22:20 Sven Verdoolaege
2005-11-29 21:15 ` Sven Verdoolaege
0 siblings, 1 reply; 9+ messages in thread
From: Sven Verdoolaege @ 2005-11-23 22:20 UTC (permalink / raw)
To: Paul Mackerras, Junio C Hamano; +Cc: git
Update will redraw the commits if any commits have been added to any
of the selected heads. The new commits appear on the top.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
Updated patch against recent gitk in case someone is interested.
Previous version has been working for without any glitches.
skimo
gitk | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 142 insertions(+), 34 deletions(-)
applies-to: c183291c9f13912f9111ee0ab2e24ac47f3147ed
6a2a3df712ce55ecbae91367b285ce295f38a558
diff --git a/gitk b/gitk
index 3dd97e2..352a319 100755
--- a/gitk
+++ b/gitk
@@ -16,8 +16,24 @@ proc gitdir {} {
}
}
+proc parse_args {rargs} {
+ global parsed_args
+
+ if [catch {
+ set parse_args [concat --default HEAD $rargs]
+ set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
+ }] {
+ # if git-rev-parse failed for some reason...
+ if {$rargs == {}} {
+ set rargs HEAD
+ }
+ set parsed_args $rargs
+ }
+ return $parsed_args
+}
+
proc getcommits {rargs} {
- global commits commfd phase canv mainfont env
+ global oldcommits commits commfd phase canv mainfont env
global startmsecs nextupdate ncmupdate
global ctext maincursor textcursor leftover
@@ -27,21 +43,13 @@ proc getcommits {rargs} {
error_popup "Cannot find the git directory \"$gitdir\"."
exit 1
}
+ set oldcommits {}
set commits {}
set phase getcommits
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100]
set ncmupdate 1
- if [catch {
- set parse_args [concat --default HEAD $rargs]
- set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
- }] {
- # if git-rev-parse failed for some reason...
- if {$rargs == {}} {
- set rargs HEAD
- }
- set parsed_args $rargs
- }
+ set parsed_args [parse_args $rargs]
if [catch {
set commfd [open "|git-rev-list --header --topo-order --parents $parsed_args" r]
} err] {
@@ -59,9 +67,10 @@ proc getcommits {rargs} {
}
proc getcommitlines {commfd} {
- global commits parents cdate children
+ global oldcommits commits parents cdate children nchildren
global commitlisted phase nextupdate
global stopped redisplaying leftover
+ global canv
set stuff [read $commfd]
if {$stuff == {}} {
@@ -119,10 +128,18 @@ to allow selection of commits to be disp
set id [lindex $ids 0]
set olds [lrange $ids 1 end]
set cmit [string range $cmit [expr {$j + 1}] end]
+ if {$phase == "updatecommits"} {
+ $canv delete all
+ set oldcommits $commits
+ set commits {}
+ unset children
+ unset nchildren
+ set phase getcommits
+ }
lappend commits $id
set commitlisted($id) 1
parsecommit $id $cmit 1 [lrange $ids 1 end]
- drawcommit $id
+ drawcommit $id 1
if {[clock clicks -milliseconds] >= $nextupdate} {
doupdate 1
}
@@ -132,7 +149,7 @@ to allow selection of commits to be disp
set stopped 0
set phase "getcommits"
foreach id $commits {
- drawcommit $id
+ drawcommit $id 1
if {$stopped} break
if {[clock clicks -milliseconds] >= $nextupdate} {
doupdate 1
@@ -168,16 +185,9 @@ proc readcommit {id} {
parsecommit $id $contents 0 {}
}
-proc parsecommit {id contents listed olds} {
- global commitinfo children nchildren parents nparents cdate ncleft
+proc updatechildren {id olds} {
+ global children nchildren parents nparents ncleft
- set inhdr 1
- set comment {}
- set headline {}
- set auname {}
- set audate {}
- set comname {}
- set comdate {}
if {![info exists nchildren($id)]} {
set children($id) {}
set nchildren($id) 0
@@ -196,6 +206,19 @@ proc parsecommit {id contents listed old
incr ncleft($p)
}
}
+}
+
+proc parsecommit {id contents listed olds} {
+ global commitinfo cdate
+
+ set inhdr 1
+ set comment {}
+ set headline {}
+ set auname {}
+ set audate {}
+ set comname {}
+ set comdate {}
+ updatechildren $id $olds
set hdrend [string first "\n\n" $contents]
if {$hdrend < 0} {
# should never happen...
@@ -243,6 +266,9 @@ proc readrefs {} {
global tagids idtags headids idheads tagcontents
global otherrefids idotherrefs
+ foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
+ catch {unset $v}
+ }
set refd [open [list | git-ls-remote [gitdir]] r]
while {0 <= [set n [gets $refd line]]} {
if {![regexp {^([0-9a-f]{40}) refs/([^^]*)$} $line \
@@ -292,7 +318,7 @@ proc error_popup msg {
tkwait window $w
}
-proc makewindow {} {
+proc makewindow {rargs} {
global canv canv2 canv3 linespc charspc ctext cflist textfont
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
@@ -302,6 +328,7 @@ proc makewindow {} {
menu .bar
.bar add cascade -label "File" -menu .bar.file
menu .bar.file
+ .bar.file add command -label "Update" -command [list updatecommits $rargs]
.bar.file add command -label "Reread references" -command rereadrefs
.bar.file add command -label "Quit" -command doquit
menu .bar.help
@@ -1416,8 +1443,9 @@ proc decidenext {{noread 0}} {
return $level
}
-proc drawcommit {id} {
+proc drawcommit {id reading} {
global phase todo nchildren datemode nextupdate revlistorder
+ global numcommits ncmupdate displayorder todo onscreen
global numcommits ncmupdate displayorder todo onscreen parents
if {$phase != "incrdraw"} {
@@ -1455,20 +1483,29 @@ proc drawcommit {id} {
}
}
}
- drawmore 1
+ drawmore $reading
}
proc finishcommits {} {
- global phase
+ global phase oldcommits commits
global canv mainfont ctext maincursor textcursor
+ global parents
- if {$phase != "incrdraw"} {
+ if {$phase == "incrdraw" || $phase == "removecommits"} {
+ foreach id $oldcommits {
+ lappend commits $id
+ updatechildren $id $parents($id)
+ drawcommit $id 0
+ }
+ set oldcommits {}
+ drawrest
+ } elseif {$phase == "updatecommits"} {
+ set phase {}
+ } else {
$canv delete all
$canv create text 3 3 -anchor nw -text "No commits selected" \
-font $mainfont -tags textitems
set phase {}
- } else {
- drawrest
}
. config -cursor $maincursor
settextcursor $textcursor
@@ -3596,9 +3633,6 @@ proc rereadrefs {} {
set ref($id) [listrefs $id]
}
}
- foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
- catch {unset $v}
- }
readrefs
set refids [lsort -unique [concat $refids [array names idtags] \
[array names idheads] [array names idotherrefs]]]
@@ -3610,6 +3644,80 @@ proc rereadrefs {} {
}
}
+proc updatecommits {rargs} {
+ global commitlisted commfd phase
+ global startmsecs nextupdate ncmupdate
+ global idtags idheads idotherrefs
+ global leftover
+ global parsed_args
+ global canv
+ global oldcommits commits
+ global parents nchildren children ncleft
+
+ set old_args $parsed_args
+ parse_args $rargs
+
+ foreach id $old_args {
+ if {![regexp {^[0-9a-f]{40}$} $id]} continue
+ if {[info exists oldref($id)]} continue
+ set oldref($id) $id
+ lappend ignoreold "^$id"
+ }
+ foreach id $parsed_args {
+ if {![regexp {^[0-9a-f]{40}$} $id]} continue
+ if {[info exists ref($id)]} continue
+ set ref($id) $id
+ lappend ignorenew "^$id"
+ }
+
+ foreach a $old_args {
+ if {![info exists ref($a)]} {
+ lappend ignorenew $a
+ }
+ }
+
+ set phase updatecommits
+ set removed_commits [split [eval exec git-rev-list $ignorenew] "\n" ]
+ if {[llength $removed_commits] > 0} {
+ $canv delete all
+ set oldcommits {}
+ foreach c $commits {
+ if {[lsearch $c $removed_commits] < 0} {
+ lappend oldcommits $c
+ } else {
+ unset commitlisted($c)
+ }
+ }
+ set commits {}
+ unset children
+ unset nchildren
+ set phase removecommits
+ }
+
+ set args {}
+ foreach a $parsed_args {
+ if {![info exists oldref($a)]} {
+ lappend args $a
+ }
+ }
+
+ readrefs
+ if [catch {
+ set commfd [open "|git-rev-list --header --topo-order --parents $args $ignoreold" r]
+ } err] {
+ puts stderr "Error executing git-rev-list: $err"
+ exit 1
+ }
+ set startmsecs [clock clicks -milliseconds]
+ set nextupdate [expr $startmsecs + 100]
+ set ncmupdate 1
+ set leftover {}
+ fconfigure $commfd -blocking 0 -translation lf
+ fileevent $commfd readable [list getcommitlines $commfd]
+ . config -cursor watch
+ settextcursor watch
+}
+
proc showtag {tag isnew} {
global ctext cflist tagcontents tagids linknum
@@ -3697,6 +3805,6 @@ set redisplaying 0
set stuffsaved 0
set patchnum 0
setcoords
-makewindow
+makewindow $revtreeargs
readrefs
getcommits $revtreeargs
---
0.99.9.GIT
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH] gitk: add Update menu item.
2005-11-23 22:20 Sven Verdoolaege
@ 2005-11-29 21:15 ` Sven Verdoolaege
2005-12-01 11:51 ` Paul Mackerras
0 siblings, 1 reply; 9+ messages in thread
From: Sven Verdoolaege @ 2005-11-29 21:15 UTC (permalink / raw)
To: Paul Mackerras, Junio C Hamano; +Cc: git
Update will redraw the commits if any commits have been added to any
of the selected heads. The new commits appear on the top.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
Junio noticed that my patch didn't work if you use path specifiers.
This update should fix this problem.
skimo
gitk | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 142 insertions(+), 34 deletions(-)
applies-to: 4000f8b8d01ad35929972c07d98d89e2280cf3d3
f24c2e402dd592f5bd5047724da30a8a5e0115eb
diff --git a/gitk b/gitk
index 730ffd9..de5c8b1 100755
--- a/gitk
+++ b/gitk
@@ -16,8 +16,24 @@ proc gitdir {} {
}
}
+proc parse_args {rargs} {
+ global parsed_args
+
+ if [catch {
+ set parse_args [concat --default HEAD $rargs]
+ set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
+ }] {
+ # if git-rev-parse failed for some reason...
+ if {$rargs == {}} {
+ set rargs HEAD
+ }
+ set parsed_args $rargs
+ }
+ return $parsed_args
+}
+
proc getcommits {rargs} {
- global commits commfd phase canv mainfont env
+ global oldcommits commits commfd phase canv mainfont env
global startmsecs nextupdate ncmupdate
global ctext maincursor textcursor leftover gitencoding
@@ -27,21 +43,13 @@ proc getcommits {rargs} {
error_popup "Cannot find the git directory \"$gitdir\"."
exit 1
}
+ set oldcommits {}
set commits {}
set phase getcommits
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr {$startmsecs + 100}]
set ncmupdate 1
- if [catch {
- set parse_args [concat --default HEAD $rargs]
- set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
- }] {
- # if git-rev-parse failed for some reason...
- if {$rargs == {}} {
- set rargs HEAD
- }
- set parsed_args $rargs
- }
+ set parsed_args [parse_args $rargs]
if [catch {
set commfd [open "|git-rev-list --header --topo-order --parents $parsed_args" r]
} err] {
@@ -59,9 +67,10 @@ proc getcommits {rargs} {
}
proc getcommitlines {commfd} {
- global commits parents cdate children
+ global oldcommits commits parents cdate children nchildren
global commitlisted phase nextupdate
global stopped redisplaying leftover
+ global canv
set stuff [read $commfd]
if {$stuff == {}} {
@@ -119,10 +128,18 @@ proc getcommitlines {commfd} {
set id [lindex $ids 0]
set olds [lrange $ids 1 end]
set cmit [string range $cmit [expr {$j + 1}] end]
+ if {$phase == "updatecommits"} {
+ $canv delete all
+ set oldcommits $commits
+ set commits {}
+ unset children
+ unset nchildren
+ set phase getcommits
+ }
lappend commits $id
set commitlisted($id) 1
parsecommit $id $cmit 1 [lrange $ids 1 end]
- drawcommit $id
+ drawcommit $id 1
if {[clock clicks -milliseconds] >= $nextupdate} {
doupdate 1
}
@@ -132,7 +149,7 @@ proc getcommitlines {commfd} {
set stopped 0
set phase "getcommits"
foreach id $commits {
- drawcommit $id
+ drawcommit $id 1
if {$stopped} break
if {[clock clicks -milliseconds] >= $nextupdate} {
doupdate 1
@@ -168,16 +185,9 @@ proc readcommit {id} {
parsecommit $id $contents 0 {}
}
-proc parsecommit {id contents listed olds} {
- global commitinfo children nchildren parents nparents cdate ncleft
+proc updatechildren {id olds} {
+ global children nchildren parents nparents ncleft
- set inhdr 1
- set comment {}
- set headline {}
- set auname {}
- set audate {}
- set comname {}
- set comdate {}
if {![info exists nchildren($id)]} {
set children($id) {}
set nchildren($id) 0
@@ -196,6 +206,19 @@ proc parsecommit {id contents listed old
incr ncleft($p)
}
}
+}
+
+proc parsecommit {id contents listed olds} {
+ global commitinfo cdate
+
+ set inhdr 1
+ set comment {}
+ set headline {}
+ set auname {}
+ set audate {}
+ set comname {}
+ set comdate {}
+ updatechildren $id $olds
set hdrend [string first "\n\n" $contents]
if {$hdrend < 0} {
# should never happen...
@@ -243,6 +266,9 @@ proc readrefs {} {
global tagids idtags headids idheads tagcontents
global otherrefids idotherrefs
+ foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
+ catch {unset $v}
+ }
set refd [open [list | git-ls-remote [gitdir]] r]
while {0 <= [set n [gets $refd line]]} {
if {![regexp {^([0-9a-f]{40}) refs/([^^]*)$} $line \
@@ -292,7 +318,7 @@ proc error_popup msg {
tkwait window $w
}
-proc makewindow {} {
+proc makewindow {rargs} {
global canv canv2 canv3 linespc charspc ctext cflist textfont
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
@@ -302,6 +328,7 @@ proc makewindow {} {
menu .bar
.bar add cascade -label "File" -menu .bar.file
menu .bar.file
+ .bar.file add command -label "Update" -command [list updatecommits $rargs]
.bar.file add command -label "Reread references" -command rereadrefs
.bar.file add command -label "Quit" -command doquit
menu .bar.help
@@ -1416,8 +1443,9 @@ proc decidenext {{noread 0}} {
return $level
}
-proc drawcommit {id} {
+proc drawcommit {id reading} {
global phase todo nchildren datemode nextupdate revlistorder
+ global numcommits ncmupdate displayorder todo onscreen
global numcommits ncmupdate displayorder todo onscreen parents
if {$phase != "incrdraw"} {
@@ -1455,20 +1483,29 @@ proc drawcommit {id} {
}
}
}
- drawmore 1
+ drawmore $reading
}
proc finishcommits {} {
- global phase
+ global phase oldcommits commits
global canv mainfont ctext maincursor textcursor
+ global parents
- if {$phase != "incrdraw"} {
+ if {$phase == "incrdraw" || $phase == "removecommits"} {
+ foreach id $oldcommits {
+ lappend commits $id
+ updatechildren $id $parents($id)
+ drawcommit $id 0
+ }
+ set oldcommits {}
+ drawrest
+ } elseif {$phase == "updatecommits"} {
+ set phase {}
+ } else {
$canv delete all
$canv create text 3 3 -anchor nw -text "No commits selected" \
-font $mainfont -tags textitems
set phase {}
- } else {
- drawrest
}
. config -cursor $maincursor
settextcursor $textcursor
@@ -3595,9 +3632,6 @@ proc rereadrefs {} {
set ref($id) [listrefs $id]
}
}
- foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
- catch {unset $v}
- }
readrefs
set refids [lsort -unique [concat $refids [array names idtags] \
[array names idheads] [array names idotherrefs]]]
@@ -3609,6 +3643,80 @@ proc rereadrefs {} {
}
}
+proc updatecommits {rargs} {
+ global commitlisted commfd phase
+ global startmsecs nextupdate ncmupdate
+ global idtags idheads idotherrefs
+ global leftover
+ global parsed_args
+ global canv
+ global oldcommits commits
+ global parents nchildren children ncleft
+
+ set old_args $parsed_args
+ parse_args $rargs
+
+ foreach id $old_args {
+ if {![regexp {^[0-9a-f]{40}$} $id]} continue
+ if {[info exists oldref($id)]} continue
+ set oldref($id) $id
+ lappend ignoreold "^$id"
+ }
+ foreach id $parsed_args {
+ if {![regexp {^[0-9a-f]{40}$} $id]} continue
+ if {[info exists ref($id)]} continue
+ set ref($id) $id
+ lappend ignorenew "^$id"
+ }
+
+ foreach a $old_args {
+ if {![info exists ref($a)]} {
+ lappend ignorenew $a
+ }
+ }
+
+ set phase updatecommits
+ set removed_commits [split [eval exec git-rev-list $ignorenew] "\n" ]
+ if {[llength $removed_commits] > 0} {
+ $canv delete all
+ set oldcommits {}
+ foreach c $commits {
+ if {[lsearch $c $removed_commits] < 0} {
+ lappend oldcommits $c
+ } else {
+ unset commitlisted($c)
+ }
+ }
+ set commits {}
+ unset children
+ unset nchildren
+ set phase removecommits
+ }
+
+ set args {}
+ foreach a $parsed_args {
+ if {![info exists oldref($a)]} {
+ lappend args $a
+ }
+ }
+
+ readrefs
+ if [catch {
+ set commfd [open "|git-rev-list --header --topo-order --parents $ignoreold $args" r]
+ } err] {
+ puts stderr "Error executing git-rev-list: $err"
+ exit 1
+ }
+ set startmsecs [clock clicks -milliseconds]
+ set nextupdate [expr $startmsecs + 100]
+ set ncmupdate 1
+ set leftover {}
+ fconfigure $commfd -blocking 0 -translation lf
+ fileevent $commfd readable [list getcommitlines $commfd]
+ . config -cursor watch
+ settextcursor watch
+}
+
proc showtag {tag isnew} {
global ctext cflist tagcontents tagids linknum
@@ -3704,6 +3812,6 @@ set redisplaying 0
set stuffsaved 0
set patchnum 0
setcoords
-makewindow
+makewindow $revtreeargs
readrefs
getcommits $revtreeargs
---
0.99.9.GIT
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH] gitk: add Update menu item.
2005-11-29 21:15 ` Sven Verdoolaege
@ 2005-12-01 11:51 ` Paul Mackerras
2005-12-01 13:07 ` Sven Verdoolaege
0 siblings, 1 reply; 9+ messages in thread
From: Paul Mackerras @ 2005-12-01 11:51 UTC (permalink / raw)
To: skimo; +Cc: Junio C Hamano, git
Sven Verdoolaege writes:
> Update will redraw the commits if any commits have been added to any
> of the selected heads. The new commits appear on the top.
I put this in although I'm not completely happy with it (though it is
a good step in the right direction).
Why do we unset children and nchildren in the phase == updatecommits
case? Wouldn't it give the same result if we set ncleft to nchildren
for each commit and then we didn't call updatechildren in
finishcommits? I think that would end up simpler.
I tried removing some commits (using git reset --hard) and then doing
selecting update from the menu, and it redrew everything, but the
removed commits were still shown.
Also, what will happen if the user selects update while gitk is still
drawing the graph? I think that will cause havoc. At _best_ we'll
end up with a truncated list of commits AFAICS. We need to make that
robust.
Paul.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gitk: add Update menu item.
2005-12-01 11:51 ` Paul Mackerras
@ 2005-12-01 13:07 ` Sven Verdoolaege
2005-12-08 7:52 ` Alex Riesen
0 siblings, 1 reply; 9+ messages in thread
From: Sven Verdoolaege @ 2005-12-01 13:07 UTC (permalink / raw)
To: Paul Mackerras; +Cc: Junio C Hamano, git
On Thu, Dec 01, 2005 at 10:51:41PM +1100, Paul Mackerras wrote:
> I put this in although I'm not completely happy with it (though it is
> a good step in the right direction).
Thanks. That's what it was meant to be (a step in the right direction).
> Why do we unset children and nchildren in the phase == updatecommits
> case? Wouldn't it give the same result if we set ncleft to nchildren
> for each commit and then we didn't call updatechildren in
> finishcommits? I think that would end up simpler.
Well, you probably know your own code better than I do,
but I'll have a look later.
> I tried removing some commits (using git reset --hard) and then doing
> selecting update from the menu, and it redrew everything, but the
> removed commits were still shown.
Hmmm... I'll have look at this over the weekend (unless you beat
me to it).
> Also, what will happen if the user selects update while gitk is still
> drawing the graph? I think that will cause havoc. At _best_ we'll
> end up with a truncated list of commits AFAICS. We need to make that
> robust.
Agreed. I hadn't thought a user would do that, but that was just
my lack of imagination.
skimo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gitk: add Update menu item.
2005-12-01 13:07 ` Sven Verdoolaege
@ 2005-12-08 7:52 ` Alex Riesen
0 siblings, 0 replies; 9+ messages in thread
From: Alex Riesen @ 2005-12-08 7:52 UTC (permalink / raw)
To: skimo, Paul Mackerras, Junio C Hamano, git
On 12/1/05, Sven Verdoolaege <skimo@kotnet.org> wrote:
> > I tried removing some commits (using git reset --hard) and then doing
> > selecting update from the menu, and it redrew everything, but the
> > removed commits were still shown.
>
> Hmmm... I'll have look at this over the weekend (unless you beat
> me to it).
Also the removed references are not removed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-12-08 7:52 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-20 12:24 [PATCH] gitk: add Update menu item Sven Verdoolaege
2005-09-20 14:56 ` Sven Verdoolaege
2005-09-21 23:46 ` Paul Mackerras
2005-09-22 13:30 ` Sven Verdoolaege
-- strict thread matches above, loose matches on Subject: below --
2005-11-23 22:20 Sven Verdoolaege
2005-11-29 21:15 ` Sven Verdoolaege
2005-12-01 11:51 ` Paul Mackerras
2005-12-01 13:07 ` Sven Verdoolaege
2005-12-08 7:52 ` Alex Riesen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox