{"thread":{"id":"9011","subject":"[PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.","startedAt":"2007-07-12T22:04:40Z","lastAt":"2007-07-22T15:49:03Z","messageCount":3,"participants":["Yann Dirson","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"47211","messageId":"20070712220411.31743.83101.stgit@gandelf.nowhere.earth","threadId":"9011","inReplyTo":null,"subject":"[PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-07-12T22:04:40Z","receivedAt":"2007-07-12T22:04:40Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"This allows to display a set of refs, when the refs in the set may\nthemselves change between two refresh operations (eg. the set of\npatches in a patch stack), and is expected to be called from other\nporcelain suites.\n\nThe command is expected to generate a list of commits, which will be\nappended to the commits litterally passed on the command-line.  That\ncommand is handled similarly to the litteral refs, and has its own\nfield in the saved view, and an edit field in the view editor.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\nThis new version causes the command to add its revs to the litteral\nones from command-line instead of overriding them, and allows to\nedit the command in the view editor.\n\nDisclaimer: I'm no tcl/tk expert, feel free to flame my style :)\n\n Documentation/gitk.txt |    7 ++++++\n gitk                   |   54 +++++++++++++++++++++++++++++++++++++++++-------\n 2 files changed, 53 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/gitk.txt b/Documentation/gitk.txt\nindex e9f82b9..71ed8ba 100644\n--- a/Documentation/gitk.txt\n+++ b/Documentation/gitk.txt\n@@ -41,6 +41,13 @@ frequently used options.\n \n \tShow all branches.\n \n+--argscmd=<command>::\n+\tCommand to be run each time gitk has to determine the list of\n+\t<revs> to show.  The command is expected to print on its\n+\tstandard output a list of additional revs to be shown.  Use\n+\tthis instead of explicitely specifying <revs> if the set of\n+\tcommits to show may vary between refreshs.\n+\n <revs>::\n \n \tLimit the revisions to show. This can be either a single revision\ndiff --git a/gitk b/gitk\nindex 2d6a6ef..4b6d31b 100755\n--- a/gitk\n+++ b/gitk\n@@ -82,12 +82,22 @@ proc dorunq {} {\n proc start_rev_list {view} {\n     global startmsecs\n     global commfd leftover tclencoding datemode\n-    global viewargs viewfiles commitidx\n+    global viewargs viewargscmd viewfiles commitidx\n     global lookingforhead showlocalchanges\n \n     set startmsecs [clock clicks -milliseconds]\n     set commitidx($view) 0\n     set args $viewargs($view)\n+    if {$viewargscmd($view) ne \"None\"} {\n+\tif {[catch {\n+\t    set fd [open [concat | $viewargscmd($view)] r]\n+\t} err]} {\n+\t    puts stderr \"Error executing --argscmd command: $err\"\n+\t    exit 1\n+\t}\n+\tset args [concat $args [read $fd 500000]]\n+\tclose $fd\n+    }\n     if {$viewfiles($view) ne {}} {\n \tset args [concat $args \"--\" $viewfiles($view)]\n     }\n@@ -943,7 +953,7 @@ proc savestuff {w} {\n     global canv canv2 canv3 ctext cflist mainfont textfont uifont tabstop\n     global stuffsaved findmergefiles maxgraphpct\n     global maxwidth showneartags showlocalchanges\n-    global viewname viewfiles viewargs viewperm nextviewnum\n+    global viewname viewfiles viewargs viewargscmd viewperm nextviewnum\n     global cmitmode wrapcomment\n     global colors bgcolor fgcolor diffcolors selectbgcolor\n \n@@ -979,7 +989,7 @@ proc savestuff {w} {\n \tputs -nonewline $f \"set permviews {\"\n \tfor {set v 0} {$v < $nextviewnum} {incr v} {\n \t    if {$viewperm($v)} {\n-\t\tputs $f \"{[list $viewname($v) $viewfiles($v) $viewargs($v)]}\"\n+\t\tputs $f \"{[list $viewname($v) $viewfiles($v) $viewargs($v) $viewargscmd($v)]}\"\n \t    }\n \t}\n \tputs $f \"}\"\n@@ -1566,7 +1576,7 @@ proc shellsplit {str} {\n \n proc newview {ishighlight} {\n     global nextviewnum newviewname newviewperm uifont newishighlight\n-    global newviewargs revtreeargs\n+    global newviewargs revtreeargs viewargscmd newviewargscmd curview\n \n     set newishighlight $ishighlight\n     set top .gitkview\n@@ -1577,13 +1587,14 @@ proc newview {ishighlight} {\n     set newviewname($nextviewnum) \"View $nextviewnum\"\n     set newviewperm($nextviewnum) 0\n     set newviewargs($nextviewnum) [shellarglist $revtreeargs]\n+    set newviewargscmd($nextviewnum) [shellarglist $viewargscmd($curview)]\n     vieweditor $top $nextviewnum \"Gitk view definition\"\n }\n \n proc editview {} {\n     global curview\n     global viewname viewperm newviewname newviewperm\n-    global viewargs newviewargs\n+    global viewargs newviewargs viewargscmd newviewargscmd\n \n     set top .gitkvedit-$curview\n     if {[winfo exists $top]} {\n@@ -1593,6 +1604,7 @@ proc editview {} {\n     set newviewname($curview) $viewname($curview)\n     set newviewperm($curview) $viewperm($curview)\n     set newviewargs($curview) [shellarglist $viewargs($curview)]\n+    set newviewargscmd($curview) [shellarglist $viewargscmd($curview)]\n     vieweditor $top $curview \"Gitk: edit view $viewname($curview)\"\n }\n \n@@ -1613,7 +1625,15 @@ proc vieweditor {top n title} {\n     grid $top.al - -sticky w -pady 5\n     entry $top.args -width 50 -textvariable newviewargs($n) \\\n \t-background white -font $uifont\n+\n     grid $top.args - -sticky ew -padx 5\n+    message $top.ac -aspect 1000 -font $uifont \\\n+\t-text \"Command to generate more commits to include:\"\n+    grid $top.ac - -sticky w -pady 5\n+    entry $top.argscmd -width 50 -textvariable newviewargscmd($n) \\\n+\t-background white -font $uifont\n+\n+    grid $top.argscmd - -sticky ew -padx 5\n     message $top.l -aspect 1000 -font $uifont \\\n \t-text \"Enter files and directories to include, one per line:\"\n     grid $top.l - -sticky w\n@@ -1659,7 +1679,7 @@ proc allviewmenus {n op args} {\n proc newviewok {top n} {\n     global nextviewnum newviewperm newviewname newishighlight\n     global viewname viewfiles viewperm selectedview curview\n-    global viewargs newviewargs viewhlmenu\n+    global viewargs newviewargs viewargscmd newviewargscmd viewhlmenu\n \n     if {[catch {\n \tset newargs [shellsplit $newviewargs($n)]\n@@ -1669,6 +1689,14 @@ proc newviewok {top n} {\n \tfocus $top\n \treturn\n     }\n+    if {[catch {\n+\tset newargscmd [shellsplit $newviewargscmd($n)]\n+    } err]} {\n+\terror_popup \"Error in commit selection command: $err\"\n+\twm raise $top\n+\tfocus $top\n+\treturn\n+    }\n     set files {}\n     foreach f [split [$top.t get 0.0 end] \"\\n\"] {\n \tset ft [string trim $f]\n@@ -1683,6 +1711,7 @@ proc newviewok {top n} {\n \tset viewperm($n) $newviewperm($n)\n \tset viewfiles($n) $files\n \tset viewargs($n) $newargs\n+\tset viewargscmd($n) $newargscmd\n \taddviewmenu $n\n \tif {!$newishighlight} {\n \t    run showview $n\n@@ -1699,9 +1728,11 @@ proc newviewok {top n} {\n \t    doviewmenu $viewhlmenu 1 [list addvhighlight $n] \\\n \t\tentryconf [list -label $viewname($n) -value $viewname($n)]\n \t}\n-\tif {$files ne $viewfiles($n) || $newargs ne $viewargs($n)} {\n+\tif {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \\\n+\t\t$newargscmd ne $viewargscmd($n)} {\n \t    set viewfiles($n) $files\n \t    set viewargs($n) $newargs\n+\t    set viewargscmd($n) $newargscmd\n \t    if {$curview == $n} {\n \t\trun updatecommits\n \t    }\n@@ -7419,10 +7450,14 @@ catch {source ~/.gitk}\n font create optionfont -family sans-serif -size -12\n \n set revtreeargs {}\n+set revtreeargscmd None\n foreach arg $argv {\n     switch -regexp -- $arg {\n \t\"^$\" { }\n \t\"^-d\" { set datemode 1 }\n+\t\"^--argscmd=\" {\n+\t    regexp {^--argscmd=(.*)} $arg match revtreeargscmd\n+\t}\n \tdefault {\n \t    lappend revtreeargs $arg\n \t}\n@@ -7481,6 +7516,7 @@ set selectedhlview None\n set viewfiles(0) {}\n set viewperm(0) 0\n set viewargs(0) {}\n+set viewargscmd(0) None\n \n set cmdlineok 0\n set stopped 0\n@@ -7494,7 +7530,7 @@ makewindow\n wm title . \"[file tail $argv0]: [file tail [pwd]]\"\n readrefs\n \n-if {$cmdline_files ne {} || $revtreeargs ne {}} {\n+if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} {\n     # create a view for the files/dirs specified on the command line\n     set curview 1\n     set selectedview 1\n@@ -7502,6 +7538,7 @@ if {$cmdline_files ne {} || $revtreeargs ne {}} {\n     set viewname(1) \"Command line\"\n     set viewfiles(1) $cmdline_files\n     set viewargs(1) $revtreeargs\n+    set viewargscmd(1) $revtreeargscmd\n     set viewperm(1) 0\n     addviewmenu 1\n     .bar.view entryconf Edit* -state normal\n@@ -7515,6 +7552,7 @@ if {[info exists permviews]} {\n \tset viewname($n) [lindex $v 0]\n \tset viewfiles($n) [lindex $v 1]\n \tset viewargs($n) [lindex $v 2]\n+\tset viewargscmd($n) [lindex $v 3]\n \tset viewperm($n) 1\n \taddviewmenu $n\n     }\n"},{"id":"48133","messageId":"18083.19607.236048.797818@cargo.ozlabs.ibm.com","threadId":"9011","inReplyTo":"20070712220411.31743.83101.stgit@gandelf.nowhere.earth","subject":"Re: [PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2007-07-22T12:24:55Z","receivedAt":"2007-07-22T12:24:55Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Yann Dirson writes:\n\n> This new version causes the command to add its revs to the litteral\n> ones from command-line instead of overriding them, and allows to\n> edit the command in the view editor.\n\nIs it actually useful to use both the --argscmd flag and some literal\nrevisions on the command line?  Why would you use both?\n\nInstead of the --argscmd flag, maybe we could have a convention that\nan argument starting with \"|\" is a command to run rather than a\nliteral revision.  Would that suit?  It would seem to simplify the\npatch by eliminating the requirement for an extra entry field, as well\nas removing the need for the separate viewargscmd array.\n\n> Disclaimer: I'm no tcl/tk expert, feel free to flame my style :)\n\nThere are a couple of things I think should be done differently, in\nfact. :)\n\nPaul.\n"},{"id":"48147","messageId":"20070722154903.GM23229@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"9011","inReplyTo":"18083.19607.236048.797818@cargo.ozlabs.ibm.com","subject":"Re: [PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-07-22T15:49:03Z","receivedAt":"2007-07-22T15:49:03Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Sun, Jul 22, 2007 at 10:24:55PM +1000, Paul Mackerras wrote:\n> Yann Dirson writes:\n> \n> > This new version causes the command to add its revs to the litteral\n> > ones from command-line instead of overriding them, and allows to\n> > edit the command in the view editor.\n> \n> Is it actually useful to use both the --argscmd flag and some literal\n> revisions on the command line?  Why would you use both?\n\nI tend to mostly use --all each time I use gitk (or stg-gitk, for that\nmatter), so my personal way of using gitk does not need it.  However,\nit could be useful if someone launched, say, 'stg-gitk master', thus\nusing --argscmd, and later wants to edit the view, eg. to add \"origin\".\n\n> Instead of the --argscmd flag, maybe we could have a convention that\n> an argument starting with \"|\" is a command to run rather than a\n> literal revision.  Would that suit?\n\nIf we go that way, a final \"|\" could be more intuitive.\n\nHowever, a final \"|\" would run into a limitation of the view editor,\nwhich is already a bit annoying with long command lines: the limited\nsize of the text field would by default hide the important final char.\n\n>  It would seem to simplify the\n> patch by eliminating the requirement for an extra entry field, as well\n> as removing the need for the separate viewargscmd array.\n\nSure, but at the same time, it does not make the code that more\ncomplicated, and it makes it obvious that there are 2 ways to specify\nthe revs.\n\n\n> > Disclaimer: I'm no tcl/tk expert, feel free to flame my style :)\n> \n> There are a couple of things I think should be done differently, in\n> fact. :)\n\nEh :)\n\nBest regards,\n-- \nYann\n"}]}