* [PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.
@ 2007-06-03 22:49 Yann Dirson
0 siblings, 0 replies; 4+ messages in thread
From: Yann Dirson @ 2007-06-03 22:49 UTC (permalink / raw)
To: paulus; +Cc: git
This flag is meant for porcelains which can modify the list of
meaningful refs to graph. It allows gitk's refresh operation to be
always up-to-date wrt the list of refs to graph.
Primary target is stg-gitk (in StGIT contrib/ dir), which requests
gitk to graph all patches in a stack: patches can be created and
deleted, so we need a way to tell gitk that something has changed.
This patch does not allow setting this parameter in a saved profile,
although it reserves a slot in the savefile format, and will read it
when it finds one.
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
Documentation/gitk.txt | 6 ++++++
gitk | 28 +++++++++++++++++++++++-----
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index 48c5894..21d002b 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -41,6 +41,12 @@ frequently used options.
Show all branches.
+--argscmd=<command>::
+ Command to be run each time gitk has to determine the list of
+ <revs> to show. Use this instead of explicitely specifying
+ <revs> if the list of commits to show may vary between
+ refreshs.
+
<revs>::
Limit the revisions to show. This can be either a single revision
diff --git a/gitk b/gitk
index a57e84c..6d4d10a 100755
--- a/gitk
+++ b/gitk
@@ -19,12 +19,23 @@ proc gitdir {} {
proc start_rev_list {view} {
global startmsecs nextupdate
global commfd leftover tclencoding datemode
- global viewargs viewfiles commitidx
+ global viewargs viewargscmd viewfiles commitidx
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr {$startmsecs + 100}]
set commitidx($view) 0
- set args $viewargs($view)
+ if {$viewargscmd($view) ne "None"} {
+ if {[catch {
+ set fd [open [concat | $viewargscmd($view)] r]
+ } err]} {
+ puts stderr "Error executing --argscmd command: $err"
+ exit 1
+ }
+ set args [read $fd 500000]
+ close $fd
+ } else {
+ set args $viewargs($view)
+ }
if {$viewfiles($view) ne {}} {
set args [concat $args "--" $viewfiles($view)]
}
@@ -823,7 +834,7 @@ proc savestuff {w} {
global canv canv2 canv3 ctext cflist mainfont textfont uifont
global stuffsaved findmergefiles maxgraphpct
global maxwidth showneartags
- global viewname viewfiles viewargs viewperm nextviewnum
+ global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
global cmitmode wrapcomment
global colors bgcolor fgcolor diffcolors
@@ -856,7 +867,7 @@ proc savestuff {w} {
puts -nonewline $f "set permviews {"
for {set v 0} {$v < $nextviewnum} {incr v} {
if {$viewperm($v)} {
- puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v)]}"
+ puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v) $viewargscmd($v)]}"
}
}
puts $f "}"
@@ -6298,10 +6309,14 @@ catch {source ~/.gitk}
font create optionfont -family sans-serif -size -12
set revtreeargs {}
+set revtreeargscmd None
foreach arg $argv {
switch -regexp -- $arg {
"^$" { }
"^-d" { set datemode 1 }
+ "^--argscmd=" {
+ regexp {^--argscmd=(.*)} $arg match revtreeargscmd
+ }
default {
lappend revtreeargs $arg
}
@@ -6357,6 +6372,7 @@ set selectedhlview None
set viewfiles(0) {}
set viewperm(0) 0
set viewargs(0) {}
+set viewargscmd(0) None
set cmdlineok 0
set stopped 0
@@ -6367,7 +6383,7 @@ makewindow
wm title . "[file tail $argv0]: [file tail [pwd]]"
readrefs
-if {$cmdline_files ne {} || $revtreeargs ne {}} {
+if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} {
# create a view for the files/dirs specified on the command line
set curview 1
set selectedview 1
@@ -6375,6 +6391,7 @@ if {$cmdline_files ne {} || $revtreeargs ne {}} {
set viewname(1) "Command line"
set viewfiles(1) $cmdline_files
set viewargs(1) $revtreeargs
+ set viewargscmd(1) $revtreeargscmd
set viewperm(1) 0
addviewmenu 1
.bar.view entryconf Edit* -state normal
@@ -6388,6 +6405,7 @@ if {[info exists permviews]} {
set viewname($n) [lindex $v 0]
set viewfiles($n) [lindex $v 1]
set viewargs($n) [lindex $v 2]
+ set viewargscmd($n) [lindex $v 3]
set viewperm($n) 1
addviewmenu $n
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.
@ 2007-07-12 22:04 Yann Dirson
2007-07-22 12:24 ` Paul Mackerras
0 siblings, 1 reply; 4+ messages in thread
From: Yann Dirson @ 2007-07-12 22:04 UTC (permalink / raw)
To: paulus; +Cc: git
This allows to display a set of refs, when the refs in the set may
themselves change between two refresh operations (eg. the set of
patches in a patch stack), and is expected to be called from other
porcelain suites.
The command is expected to generate a list of commits, which will be
appended to the commits litterally passed on the command-line. That
command is handled similarly to the litteral refs, and has its own
field in the saved view, and an edit field in the view editor.
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
This new version causes the command to add its revs to the litteral
ones from command-line instead of overriding them, and allows to
edit the command in the view editor.
Disclaimer: I'm no tcl/tk expert, feel free to flame my style :)
Documentation/gitk.txt | 7 ++++++
gitk | 54 +++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index e9f82b9..71ed8ba 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -41,6 +41,13 @@ frequently used options.
Show all branches.
+--argscmd=<command>::
+ Command to be run each time gitk has to determine the list of
+ <revs> to show. The command is expected to print on its
+ standard output a list of additional revs to be shown. Use
+ this instead of explicitely specifying <revs> if the set of
+ commits to show may vary between refreshs.
+
<revs>::
Limit the revisions to show. This can be either a single revision
diff --git a/gitk b/gitk
index 2d6a6ef..4b6d31b 100755
--- a/gitk
+++ b/gitk
@@ -82,12 +82,22 @@ proc dorunq {} {
proc start_rev_list {view} {
global startmsecs
global commfd leftover tclencoding datemode
- global viewargs viewfiles commitidx
+ global viewargs viewargscmd viewfiles commitidx
global lookingforhead showlocalchanges
set startmsecs [clock clicks -milliseconds]
set commitidx($view) 0
set args $viewargs($view)
+ if {$viewargscmd($view) ne "None"} {
+ if {[catch {
+ set fd [open [concat | $viewargscmd($view)] r]
+ } err]} {
+ puts stderr "Error executing --argscmd command: $err"
+ exit 1
+ }
+ set args [concat $args [read $fd 500000]]
+ close $fd
+ }
if {$viewfiles($view) ne {}} {
set args [concat $args "--" $viewfiles($view)]
}
@@ -943,7 +953,7 @@ proc savestuff {w} {
global canv canv2 canv3 ctext cflist mainfont textfont uifont tabstop
global stuffsaved findmergefiles maxgraphpct
global maxwidth showneartags showlocalchanges
- global viewname viewfiles viewargs viewperm nextviewnum
+ global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
global cmitmode wrapcomment
global colors bgcolor fgcolor diffcolors selectbgcolor
@@ -979,7 +989,7 @@ proc savestuff {w} {
puts -nonewline $f "set permviews {"
for {set v 0} {$v < $nextviewnum} {incr v} {
if {$viewperm($v)} {
- puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v)]}"
+ puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v) $viewargscmd($v)]}"
}
}
puts $f "}"
@@ -1566,7 +1576,7 @@ proc shellsplit {str} {
proc newview {ishighlight} {
global nextviewnum newviewname newviewperm uifont newishighlight
- global newviewargs revtreeargs
+ global newviewargs revtreeargs viewargscmd newviewargscmd curview
set newishighlight $ishighlight
set top .gitkview
@@ -1577,13 +1587,14 @@ proc newview {ishighlight} {
set newviewname($nextviewnum) "View $nextviewnum"
set newviewperm($nextviewnum) 0
set newviewargs($nextviewnum) [shellarglist $revtreeargs]
+ set newviewargscmd($nextviewnum) [shellarglist $viewargscmd($curview)]
vieweditor $top $nextviewnum "Gitk view definition"
}
proc editview {} {
global curview
global viewname viewperm newviewname newviewperm
- global viewargs newviewargs
+ global viewargs newviewargs viewargscmd newviewargscmd
set top .gitkvedit-$curview
if {[winfo exists $top]} {
@@ -1593,6 +1604,7 @@ proc editview {} {
set newviewname($curview) $viewname($curview)
set newviewperm($curview) $viewperm($curview)
set newviewargs($curview) [shellarglist $viewargs($curview)]
+ set newviewargscmd($curview) [shellarglist $viewargscmd($curview)]
vieweditor $top $curview "Gitk: edit view $viewname($curview)"
}
@@ -1613,7 +1625,15 @@ proc vieweditor {top n title} {
grid $top.al - -sticky w -pady 5
entry $top.args -width 50 -textvariable newviewargs($n) \
-background white -font $uifont
+
grid $top.args - -sticky ew -padx 5
+ message $top.ac -aspect 1000 -font $uifont \
+ -text "Command to generate more commits to include:"
+ grid $top.ac - -sticky w -pady 5
+ entry $top.argscmd -width 50 -textvariable newviewargscmd($n) \
+ -background white -font $uifont
+
+ grid $top.argscmd - -sticky ew -padx 5
message $top.l -aspect 1000 -font $uifont \
-text "Enter files and directories to include, one per line:"
grid $top.l - -sticky w
@@ -1659,7 +1679,7 @@ proc allviewmenus {n op args} {
proc newviewok {top n} {
global nextviewnum newviewperm newviewname newishighlight
global viewname viewfiles viewperm selectedview curview
- global viewargs newviewargs viewhlmenu
+ global viewargs newviewargs viewargscmd newviewargscmd viewhlmenu
if {[catch {
set newargs [shellsplit $newviewargs($n)]
@@ -1669,6 +1689,14 @@ proc newviewok {top n} {
focus $top
return
}
+ if {[catch {
+ set newargscmd [shellsplit $newviewargscmd($n)]
+ } err]} {
+ error_popup "Error in commit selection command: $err"
+ wm raise $top
+ focus $top
+ return
+ }
set files {}
foreach f [split [$top.t get 0.0 end] "\n"] {
set ft [string trim $f]
@@ -1683,6 +1711,7 @@ proc newviewok {top n} {
set viewperm($n) $newviewperm($n)
set viewfiles($n) $files
set viewargs($n) $newargs
+ set viewargscmd($n) $newargscmd
addviewmenu $n
if {!$newishighlight} {
run showview $n
@@ -1699,9 +1728,11 @@ proc newviewok {top n} {
doviewmenu $viewhlmenu 1 [list addvhighlight $n] \
entryconf [list -label $viewname($n) -value $viewname($n)]
}
- if {$files ne $viewfiles($n) || $newargs ne $viewargs($n)} {
+ if {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \
+ $newargscmd ne $viewargscmd($n)} {
set viewfiles($n) $files
set viewargs($n) $newargs
+ set viewargscmd($n) $newargscmd
if {$curview == $n} {
run updatecommits
}
@@ -7419,10 +7450,14 @@ catch {source ~/.gitk}
font create optionfont -family sans-serif -size -12
set revtreeargs {}
+set revtreeargscmd None
foreach arg $argv {
switch -regexp -- $arg {
"^$" { }
"^-d" { set datemode 1 }
+ "^--argscmd=" {
+ regexp {^--argscmd=(.*)} $arg match revtreeargscmd
+ }
default {
lappend revtreeargs $arg
}
@@ -7481,6 +7516,7 @@ set selectedhlview None
set viewfiles(0) {}
set viewperm(0) 0
set viewargs(0) {}
+set viewargscmd(0) None
set cmdlineok 0
set stopped 0
@@ -7494,7 +7530,7 @@ makewindow
wm title . "[file tail $argv0]: [file tail [pwd]]"
readrefs
-if {$cmdline_files ne {} || $revtreeargs ne {}} {
+if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} {
# create a view for the files/dirs specified on the command line
set curview 1
set selectedview 1
@@ -7502,6 +7538,7 @@ if {$cmdline_files ne {} || $revtreeargs ne {}} {
set viewname(1) "Command line"
set viewfiles(1) $cmdline_files
set viewargs(1) $revtreeargs
+ set viewargscmd(1) $revtreeargscmd
set viewperm(1) 0
addviewmenu 1
.bar.view entryconf Edit* -state normal
@@ -7515,6 +7552,7 @@ if {[info exists permviews]} {
set viewname($n) [lindex $v 0]
set viewfiles($n) [lindex $v 1]
set viewargs($n) [lindex $v 2]
+ set viewargscmd($n) [lindex $v 3]
set viewperm($n) 1
addviewmenu $n
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.
2007-07-12 22:04 Yann Dirson
@ 2007-07-22 12:24 ` Paul Mackerras
2007-07-22 15:49 ` Yann Dirson
0 siblings, 1 reply; 4+ messages in thread
From: Paul Mackerras @ 2007-07-22 12:24 UTC (permalink / raw)
To: Yann Dirson; +Cc: git
Yann Dirson writes:
> This new version causes the command to add its revs to the litteral
> ones from command-line instead of overriding them, and allows to
> edit the command in the view editor.
Is it actually useful to use both the --argscmd flag and some literal
revisions on the command line? Why would you use both?
Instead of the --argscmd flag, maybe we could have a convention that
an argument starting with "|" is a command to run rather than a
literal revision. Would that suit? It would seem to simplify the
patch by eliminating the requirement for an extra entry field, as well
as removing the need for the separate viewargscmd array.
> Disclaimer: I'm no tcl/tk expert, feel free to flame my style :)
There are a couple of things I think should be done differently, in
fact. :)
Paul.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.
2007-07-22 12:24 ` Paul Mackerras
@ 2007-07-22 15:49 ` Yann Dirson
0 siblings, 0 replies; 4+ messages in thread
From: Yann Dirson @ 2007-07-22 15:49 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
On Sun, Jul 22, 2007 at 10:24:55PM +1000, Paul Mackerras wrote:
> Yann Dirson writes:
>
> > This new version causes the command to add its revs to the litteral
> > ones from command-line instead of overriding them, and allows to
> > edit the command in the view editor.
>
> Is it actually useful to use both the --argscmd flag and some literal
> revisions on the command line? Why would you use both?
I tend to mostly use --all each time I use gitk (or stg-gitk, for that
matter), so my personal way of using gitk does not need it. However,
it could be useful if someone launched, say, 'stg-gitk master', thus
using --argscmd, and later wants to edit the view, eg. to add "origin".
> Instead of the --argscmd flag, maybe we could have a convention that
> an argument starting with "|" is a command to run rather than a
> literal revision. Would that suit?
If we go that way, a final "|" could be more intuitive.
However, a final "|" would run into a limitation of the view editor,
which is already a bit annoying with long command lines: the limited
size of the text field would by default hide the important final char.
> It would seem to simplify the
> patch by eliminating the requirement for an extra entry field, as well
> as removing the need for the separate viewargscmd array.
Sure, but at the same time, it does not make the code that more
complicated, and it makes it obvious that there are 2 ways to specify
the revs.
> > Disclaimer: I'm no tcl/tk expert, feel free to flame my style :)
>
> There are a couple of things I think should be done differently, in
> fact. :)
Eh :)
Best regards,
--
Yann
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-22 15:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-03 22:49 [PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time Yann Dirson
-- strict thread matches above, loose matches on Subject: below --
2007-07-12 22:04 Yann Dirson
2007-07-22 12:24 ` Paul Mackerras
2007-07-22 15:49 ` Yann Dirson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).