Patchwork [2,of,5] convert: add config to not convert tags

login
register
mail settings
Submitter Durham Goode
Date June 30, 2015, 1:44 a.m.
Message ID <2fb1cd9032338750bfe1.1435628642@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/9823/
State Superseded
Commit 86fe3c404c1e70d9960679c260f9d0e42b86358b
Headers show

Comments

Durham Goode - June 30, 2015, 1:44 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1435610420 25200
#      Mon Jun 29 13:40:20 2015 -0700
# Node ID 2fb1cd9032338750bfe16e0c21933bbb622c9da0
# Parent  af9d42a3e9c6d03411e7713cf174ada52c81472c
convert: add config to not convert tags

In some cases we do not want to convert tags from the source repo to be tags in
the target repo (for instance, in a large repository, hgtags cause scaling
issues so we want to avoid them). This adds a config option to disable
converting tags.
Matt Mackall - July 1, 2015, 7:40 p.m.
On Mon, 2015-06-29 at 18:44 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1435610420 25200
> #      Mon Jun 29 13:40:20 2015 -0700
> # Node ID 2fb1cd9032338750bfe16e0c21933bbb622c9da0
> # Parent  af9d42a3e9c6d03411e7713cf174ada52c81472c
> convert: add config to not convert tags

Needs a doc mention.

Patch

diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -460,22 +460,23 @@  class converter(object):
                 self.copy(c)
             self.ui.progress(_('converting'), None)
 
-            tags = self.source.gettags()
-            ctags = {}
-            for k in tags:
-                v = tags[k]
-                if self.map.get(v, SKIPREV) != SKIPREV:
-                    ctags[k] = self.map[v]
+            if not self.ui.configbool('convert', 'skiptags'):
+                tags = self.source.gettags()
+                ctags = {}
+                for k in tags:
+                    v = tags[k]
+                    if self.map.get(v, SKIPREV) != SKIPREV:
+                        ctags[k] = self.map[v]
 
-            if c and ctags:
-                nrev, tagsparent = self.dest.puttags(ctags)
-                if nrev and tagsparent:
-                    # write another hash correspondence to override the previous
-                    # one so we don't end up with extra tag heads
-                    tagsparents = [e for e in self.map.iteritems()
-                                   if e[1] == tagsparent]
-                    if tagsparents:
-                        self.map[tagsparents[0][0]] = nrev
+                if c and ctags:
+                    nrev, tagsparent = self.dest.puttags(ctags)
+                    if nrev and tagsparent:
+                        # write another hash correspondence to override the
+                        # previous one so we don't end up with extra tag heads
+                        tagsparents = [e for e in self.map.iteritems()
+                                       if e[1] == tagsparent]
+                        if tagsparents:
+                            self.map[tagsparents[0][0]] = nrev
 
             bookmarks = self.source.getbookmarks()
             cbookmarks = {}
diff --git a/tests/test-convert-tagsbranch-topology.t b/tests/test-convert-tagsbranch-topology.t
--- a/tests/test-convert-tagsbranch-topology.t
+++ b/tests/test-convert-tagsbranch-topology.t
@@ -45,6 +45,19 @@  Build a GIT repo with at least 1 tag
   $ action tag -m "tag1" tag1
   $ cd ..
 
+Convert without tags
+
+  $ hg convert git-repo hg-repo --config convert.skiptags=True
+  initializing destination hg-repo repository
+  scanning source...
+  sorting...
+  converting...
+  0 rev1
+  updating bookmarks
+  $ hg -R hg-repo tags
+  tip                                0:d98c8ad3a4cf
+  $ rm -rf hg-repo
+
 Do a first conversion
 
   $ convertrepo