changeset 26077:e63d05fbae84

convert: add convert.git.skipsubmodules option This adds an option to not pull in gitsubmodules during a convert. This is useful when converting large git repositories where gitsubmodules were allowed historically, but are no longer wanted.
author Durham Goode <durham@fb.com>
date Mon, 24 Aug 2015 22:16:01 -0700
parents cebf7e48365e
children 5ca587348875
files hgext/convert/__init__.py hgext/convert/git.py tests/test-convert-git.t tests/test-convert.t
diffstat 4 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/__init__.py	Mon Aug 24 19:33:36 2015 -0700
+++ b/hgext/convert/__init__.py	Mon Aug 24 22:16:01 2015 -0700
@@ -316,6 +316,9 @@
         ``convert.git.remoteprefix`` as a prefix followed by a /. The default
         is 'remote'.
 
+    :convert.git.skipsubmodules: does not convert root level .gitmodules files
+        or files with 160000 mode indicating a submodule. Default is False.
+
     Perforce Source
     ###############
 
--- a/hgext/convert/git.py	Mon Aug 24 19:33:36 2015 -0700
+++ b/hgext/convert/git.py	Mon Aug 24 22:16:01 2015 -0700
@@ -224,6 +224,8 @@
         lcount = len(difftree)
         i = 0
 
+        skipsubmodules = self.ui.configbool('convert', 'git.skipsubmodules',
+                                            False)
         def add(entry, f, isdest):
             seen.add(f)
             h = entry[3]
@@ -232,6 +234,9 @@
             renamesource = (not isdest and entry[4][0] == 'R')
 
             if f == '.gitmodules':
+                if skipsubmodules:
+                    return
+
                 subexists[0] = True
                 if entry[4] == 'D' or renamesource:
                     subdeleted[0] = True
@@ -239,7 +244,8 @@
                 else:
                     changes.append(('.hgsub', ''))
             elif entry[1] == '160000' or entry[0] == ':160000':
-                subexists[0] = True
+                if not skipsubmodules:
+                    subexists[0] = True
             else:
                 if renamesource:
                     h = hex(nullid)
--- a/tests/test-convert-git.t	Mon Aug 24 19:33:36 2015 -0700
+++ b/tests/test-convert-git.t	Mon Aug 24 22:16:01 2015 -0700
@@ -652,6 +652,12 @@
   $ hg -R git-repo6-hg tip -T "{file_dels}\n"
   .hgsub .hgsubstate
 
+skip submodules in the conversion
+
+  $ hg convert -q git-repo6 no-submodules --config convert.git.skipsubmodules=True
+  $ hg -R no-submodules manifest --all
+  .gitmodules-renamed
+
 convert using a different remote prefix
   $ git init git-repo7
   Initialized empty Git repository in $TESTTMP/git-repo7/.git/
--- a/tests/test-convert.t	Mon Aug 24 19:33:36 2015 -0700
+++ b/tests/test-convert.t	Mon Aug 24 22:16:01 2015 -0700
@@ -265,6 +265,9 @@
                     remote refs are converted as bookmarks with
                     "convert.git.remoteprefix" as a prefix followed by a /. The
                     default is 'remote'.
+      convert.git.skipsubmodules
+                    does not convert root level .gitmodules files or files with
+                    160000 mode indicating a submodule. Default is False.
   
       Perforce Source
       ###############