{"thread":{"id":"8419","subject":"[PATCH] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.","startedAt":"2007-06-03T22:49:50Z","lastAt":"2007-06-03T22:49:50Z","messageCount":1,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43920","messageId":"20070603224449.29875.24010.stgit@gandelf.nowhere.earth","threadId":"8419","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-06-03T22:49:50Z","receivedAt":"2007-06-03T22:49:50Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"This flag is meant for porcelains which can modify the list of\nmeaningful refs to graph.  It allows gitk's refresh operation to be\nalways up-to-date wrt the list of refs to graph.\n\nPrimary target is stg-gitk (in StGIT contrib/ dir), which requests\ngitk to graph all patches in a stack: patches can be created and\ndeleted, so we need a way to tell gitk that something has changed.\n\n\nThis patch does not allow setting this parameter in a saved profile,\nalthough it reserves a slot in the savefile format, and will read it\nwhen it finds one.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n Documentation/gitk.txt |    6 ++++++\n gitk                   |   28 +++++++++++++++++++++++-----\n 2 files changed, 29 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/gitk.txt b/Documentation/gitk.txt\nindex 48c5894..21d002b 100644\n--- a/Documentation/gitk.txt\n+++ b/Documentation/gitk.txt\n@@ -41,6 +41,12 @@ 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.  Use this instead of explicitely specifying\n+\t<revs> if the list of commits to show may vary between\n+\trefreshs.\n+\n <revs>::\n \n \tLimit the revisions to show. This can be either a single revision\ndiff --git a/gitk b/gitk\nindex a57e84c..6d4d10a 100755\n--- a/gitk\n+++ b/gitk\n@@ -19,12 +19,23 @@ proc gitdir {} {\n proc start_rev_list {view} {\n     global startmsecs nextupdate\n     global commfd leftover tclencoding datemode\n-    global viewargs viewfiles commitidx\n+    global viewargs viewargscmd viewfiles commitidx\n \n     set startmsecs [clock clicks -milliseconds]\n     set nextupdate [expr {$startmsecs + 100}]\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 [read $fd 500000]\n+\tclose $fd\n+    } else {\n+\tset args $viewargs($view)\n+    }\n     if {$viewfiles($view) ne {}} {\n \tset args [concat $args \"--\" $viewfiles($view)]\n     }\n@@ -823,7 +834,7 @@ proc savestuff {w} {\n     global canv canv2 canv3 ctext cflist mainfont textfont uifont\n     global stuffsaved findmergefiles maxgraphpct\n     global maxwidth showneartags\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\n \n@@ -856,7 +867,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@@ -6298,10 +6309,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@@ -6357,6 +6372,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@@ -6367,7 +6383,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@@ -6375,6 +6391,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@@ -6388,6 +6405,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"}]}