Patchwork [6,of,8] convert: avoid updating tags when there is nothing new

login
register
mail settings
Submitter Sean Farley
Date Feb. 4, 2014, 12:09 a.m.
Message ID <dbfab8233ee5d78d8a1c.1391472577@laptop.local>
Download mbox | patch
Permalink /patch/3462/
State Accepted
Commit 5842d63cfe56b32a8d09ee78e028b64a51c5b4f6
Headers show

Comments

Sean Farley - Feb. 4, 2014, 12:09 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1390426284 21600
#      Wed Jan 22 15:31:24 2014 -0600
# Node ID dbfab8233ee5d78d8a1c07c59be7aed0270625bf
# Parent  796d623d765b800f91ca4b3d17e6d31f22e550cb
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.

Patch

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -209,10 +209,29 @@  class mercurial_sink(converter_sink):
         oldlines = sorted(list(oldlines))
 
         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)
 
         self.ui.status(_("updating tags\n"))