changeset 20377:5842d63cfe56

convert: avoid updating tags when there is nothing new Previously, when converting from a mercurial repo there would be an extraneous commit at the end of the convert process that would rewrite tags. Now, we check if there are any new tags before doing this rewriting.
author Sean Farley <sean.michael.farley@gmail.com>
date Wed, 22 Jan 2014 15:31:24 -0600
parents 7a4797910205
children 9616b03113ce
files hgext/convert/hg.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/hg.py	Wed Jan 22 17:38:05 2014 -0600
+++ b/hgext/convert/hg.py	Wed Jan 22 15:31:24 2014 -0600
@@ -212,6 +212,25 @@
         newlines = sorted([("%s %s\n" % (tags[tag], tag)) for tag in tags])
         if newlines == oldlines:
             return None, None
+
+        # if the old and new tags match, then there is nothing to update
+        oldtags = set()
+        newtags = set()
+        for line in oldlines:
+            s = line.strip().split(' ', 1)
+            if len(s) != 2:
+                continue
+            oldtags.add(s[1])
+        for line in newlines:
+            s = line.strip().split(' ', 1)
+            if len(s) != 2:
+                continue
+            if s[1] not in oldtags:
+                newtags.add(s[1].strip())
+
+        if not newtags:
+            return None, None
+
         data = "".join(newlines)
         def getfilectx(repo, memctx, f):
             return context.memfilectx(f, data, False, False, None)