[PATCH] hgk: fix tag list parser (issue4101)

Andrew Shadura andrew at shadura.me
Fri Nov 29 07:49:22 CST 2013


# HG changeset patch
# User Andrew Shadura <andrew at 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.

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]

-- 
Cheers,
  Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20131129/824f2aad/attachment.pgp>


More information about the Mercurial-devel mailing list