[PATCH 5 of 9] hgk: simplify tags parser
Andrew Shadura
bugzilla at tut.by
Wed Nov 7 09:15:13 CST 2012
# HG changeset patch
# User Andrew Shadura <bugzilla at tut.by>
# Date 1350420104 -7200
# Node ID e20636735bc3cf6d3aa5f8f8057016567b5bae1d
# Parent d4650496805c0c5f4e7d7cac1c67789f0faeccb8
hgk: simplify tags parser.
diff --git a/contrib/hgk b/contrib/hgk
--- a/contrib/hgk
+++ b/contrib/hgk
@@ -413,16 +413,13 @@ proc readrefs {} {
exit 2
}
}
- regsub -all "\r\n" $tags "\n" tags
-
- set lines [split $tags "\n"]
+ set tags [string map {\r\n \n} $tags]
+
+ set lines [split $tags \n]
foreach f $lines {
- regexp {(\S+)$} $f full
- regsub {\s+(\S+)$} $f "" direct
- set sha [split $full ':']
- set tag [lindex $sha 1]
- lappend tagids($direct) $tag
- lappend idtags($tag) $direct
+ regexp {(\S+)\s+(\S+):(\S+)$} $f -> tag - id
+ lappend tagids($tag) $id
+ lappend idtags($id) $tag
}
set status [catch {exec $env(HG) --config ui.report_untrusted=false heads} heads]
More information about the Mercurial-devel
mailing list