[PATCH] convert: add convert.git.skipsubmodules option

Augie Fackler raf at durin42.com
Thu Aug 27 10:17:52 CDT 2015


On Tue, Aug 25, 2015 at 05:11:23PM -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1440479761 25200
> #      Mon Aug 24 22:16:01 2015 -0700
> # Node ID 23af921355e9a0e056215c1fc9aa1914206de2a3
> # Parent  05e7f57c74ac5b556b49870af86f61aa0c54babb
> convert: add convert.git.skipsubmodules option

Seems reasonable, queued, thanks.

>
> 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.
>
> diff --git a/hgext/convert/__init__.py b/hgext/convert/__init__.py
> --- a/hgext/convert/__init__.py
> +++ b/hgext/convert/__init__.py
> @@ -316,6 +316,9 @@ def convert(ui, src, dest=None, revmapfi
>          ``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
>      ###############
>
> diff --git a/hgext/convert/git.py b/hgext/convert/git.py
> --- a/hgext/convert/git.py
> +++ b/hgext/convert/git.py
> @@ -224,6 +224,8 @@ class convert_git(converter_source):
>          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 @@ class convert_git(converter_source):
>              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 @@ class convert_git(converter_source):
>                  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)
> diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
> --- a/tests/test-convert-git.t
> +++ b/tests/test-convert-git.t
> @@ -652,6 +652,12 @@ submodules)
>    $ 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/
> diff --git a/tests/test-convert.t b/tests/test-convert.t
> --- a/tests/test-convert.t
> +++ b/tests/test-convert.t
> @@ -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
>        ###############
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list