changeset 25741:86fe3c404c1e

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.
author Durham Goode <durham@fb.com>
date Mon, 29 Jun 2015 13:40:20 -0700
parents 47469fa8fb01
children d859123e0f47
files hgext/convert/__init__.py hgext/convert/convcmd.py tests/test-convert-tagsbranch-topology.t tests/test-convert.t
diffstat 4 files changed, 46 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/__init__.py	Thu Jul 02 22:18:21 2015 +0900
+++ b/hgext/convert/__init__.py	Mon Jun 29 13:40:20 2015 -0700
@@ -355,6 +355,14 @@
 
     :convert.hg.usebranchnames: preserve branch names. The default is
         True.
+
+    All Destinations
+    ################
+
+    All destination types accept the following options:
+
+    :convert.skiptags: does not convert tags from the source repo to the target
+        repo. The default is False.
     """
     return convcmd.convert(ui, src, dest, revmapfile, **opts)
 
--- a/hgext/convert/convcmd.py	Thu Jul 02 22:18:21 2015 +0900
+++ b/hgext/convert/convcmd.py	Mon Jun 29 13:40:20 2015 -0700
@@ -460,22 +460,23 @@
                 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 = {}
--- a/tests/test-convert-tagsbranch-topology.t	Thu Jul 02 22:18:21 2015 +0900
+++ b/tests/test-convert-tagsbranch-topology.t	Mon Jun 29 13:40:20 2015 -0700
@@ -45,6 +45,19 @@
   $ 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
--- a/tests/test-convert.t	Thu Jul 02 22:18:21 2015 +0900
+++ b/tests/test-convert.t	Mon Jun 29 13:40:20 2015 -0700
@@ -295,6 +295,15 @@
       convert.hg.usebranchnames
                     preserve branch names. The default is True.
   
+      All Destinations
+      ################
+  
+      All destination types accept the following options:
+  
+      convert.skiptags
+                    does not convert tags from the source repo to the target
+                    repo. The default is False.
+  
   options:
   
    -s --source-type TYPE source repository type