{"thread":{"id":"9288","subject":"[PATCH v3] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.","startedAt":"2007-07-29T12:17:47Z","lastAt":"2007-07-29T12:17:47Z","messageCount":1,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"48982","messageId":"20070729121123.3262.38879.stgit@gandelf.nowhere.earth","threadId":"9288","inReplyTo":null,"subject":"[PATCH v3] 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-29T12:17:47Z","receivedAt":"2007-07-29T12:17:47Z","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 is a rebase to current git master.  It happens that I had to\nrevert 2 code simplifications you did under \"Improve handling of --\nand ambiguous arguments\", which my patch happens to rely on in its\ncurrent form.\n\n Documentation/gitk.txt |    7 +++++\n gitk                   |   65 ++++++++++++++++++++++++++++++++++++++----------\n 2 files changed, 59 insertions(+), 13 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 f74ce51..264500f 100755\n--- a/gitk\n+++ b/gitk\n@@ -82,18 +82,29 @@ 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     set order \"--topo-order\"\n     if {$datemode} {\n \tset order \"--date-order\"\n     }\n     if {[catch {\n \tset fd [open [concat | git log -z --pretty=raw $order --parents \\\n-\t\t\t --boundary $viewargs($view) \"--\" $viewfiles($view)] r]\n+\t\t\t --boundary $args \"--\" $viewfiles($view)] r]\n     } err]} {\n \terror_popup \"Error executing git rev-list: $err\"\n \texit 1\n@@ -966,7 +977,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@@ -1002,7 +1013,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@@ -1597,7 +1608,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@@ -1608,13 +1619,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@@ -1624,6 +1636,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@@ -1644,7 +1657,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@@ -1690,7 +1711,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@@ -1700,6 +1721,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@@ -1714,6 +1743,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@@ -1730,9 +1760,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@@ -7584,14 +7616,18 @@ if {![file isdirectory $gitdir]} {\n set revtreeargs {}\n set cmdline_files {}\n set i 0\n+set revtreeargscmd None\n foreach arg $argv {\n-    switch -- $arg {\n-\t\"\" { }\n-\t\"-d\" { set datemode 1 }\n-\t\"--\" {\n+    switch -regexp -- $arg {\n+\t\"^$\" { }\n+\t\"^-d\" { set datemode 1 }\n+\t\"^--$\" {\n \t    set cmdline_files [lrange $argv [expr {$i + 1}] end]\n \t    break\n \t}\n+\t\"^--argscmd=\" {\n+\t    regexp {^--argscmd=(.*)} $arg match revtreeargscmd\n+\t}\n \tdefault {\n \t    lappend revtreeargs $arg\n \t}\n@@ -7653,6 +7689,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@@ -7669,7 +7706,7 @@ tkwait visibility .\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@@ -7677,6 +7714,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@@ -7690,6 +7728,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"}]}