From patchwork Fri Nov 29 13:49:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: hgk: fix tag list parser (issue4101) From: Andrew Shadura X-Patchwork-Id: 3191 Message-Id: <20131129144922.39e1c102@quaphany> To: mercurial-devel@selenic.com Date: Fri, 29 Nov 2013 14:49:22 +0100 # HG changeset patch # User Andrew Shadura 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]