[PATCH 5 of 8] convert: compare tags from all heads instead of just one

Sean Farley sean.michael.farley at gmail.com
Mon Feb 3 18:09:36 CST 2014


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1390433885 21600
#      Wed Jan 22 17:38:05 2014 -0600
# Node ID 796d623d765b800f91ca4b3d17e6d31f22e550cb
# Parent  2683b86e1c19445be3ba676203264b1e88afec0e
convert: compare tags from all heads instead of just one

Previously, the hg sink for puttags would just use one head for getting the old
tags which would sometimes lead to tags disappearing. Now, we iterate over all
heads and merge the results.

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -199,14 +199,16 @@ class mercurial_sink(converter_sink):
             tagparent = parentctx.node()
         except error.RepoError:
             parentctx = None
             tagparent = nullid
 
-        try:
-            oldlines = sorted(parentctx['.hgtags'].data().splitlines(True))
-        except Exception:
-            oldlines = []
+        oldlines = set()
+        for branch, heads in self.repo.branchmap().iteritems():
+            for h in heads:
+                if '.hgtags' in self.repo[h]:
+                    oldlines.update(set(self.repo[h]['.hgtags'].data().splitlines(True)))
+        oldlines = sorted(list(oldlines))
 
         newlines = sorted([("%s %s\n" % (tags[tag], tag)) for tag in tags])
         if newlines == oldlines:
             return None, None
         data = "".join(newlines)


More information about the Mercurial-devel mailing list