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

login
register
mail settings
Submitter Sean Farley
Date Feb. 4, 2014, 12:09 a.m.
Message ID <796d623d765b800f91ca.1391472576@laptop.local>
Download mbox | patch
Permalink /patch/3461/
State Accepted
Commit 7a479791020585f377cac0da9f287d2becd1439a
Headers show

Comments

Sean Farley - Feb. 4, 2014, 12:09 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@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.

Patch

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)