Patchwork hgk: fix tag list parser (issue4101)

login
register
mail settings
Submitter Andrew Shadura
Date Nov. 29, 2013, 1:49 p.m.
Message ID <20131129144922.39e1c102@quaphany>
Download mbox | patch
Permalink /patch/3191/
State Accepted
Commit 970394b6bd9748925ae5fb1f45e8e99af016b2df
Headers show

Comments

Andrew Shadura - Nov. 29, 2013, 1:49 p.m.
# HG changeset patch
# User Andrew Shadura <andrew@shadura.me>
hgk: fix tag list parser (issue4101)

As tags may have embedded spaces, and "hg tags" command doesn't escape them,
the output of the command doesn't make a well-formed list, so we can't just
iterate over it. Instead, apply a simple regexp to transform it to a list
which we actually use. Line boundary matching should be enabled.
Matt Mackall - Dec. 1, 2013, 7:55 p.m.
On Fri, 2013-11-29 at 14:49 +0100, Andrew Shadura wrote:
> # HG changeset patch
> # User Andrew Shadura <andrew@shadura.me>
> hgk: fix tag list parser (issue4101)

Queued for _stable_, thanks. Your MUA put in a bunch of nasty QP gunk,
consider using 'hg email' in the future.

Patch

diff --git a/contrib/hgk b/contrib/hgk
--- a/contrib/hgk
+++ b/contrib/hgk
@@ -472,12 +472,10 @@ 
         }
     }
 
-    foreach {tag rev} $tags {
+    foreach {- tag rev id} [regexp -inline -all -line {^(.+\S)\s+(\d+):(\S+)} $tags] {
         # we use foreach as Tcl8.4 doesn't support lassign
-        foreach {- id} [split $rev :] {
-            lappend tagids($tag) $id
-            lappend idtags($id) $tag
-        }
+        lappend tagids($tag) $id
+        lappend idtags($id) $tag
     }
 
     set status [catch {exec $env(HG) --config ui.report_untrusted=false heads} heads]