[PATCH] convert: allow customizing git remote prefix
Durham Goode
durham at fb.com
Tue Jul 14 05:07:56 UTC 2015
# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1436848666 25200
# Mon Jul 13 21:37:46 2015 -0700
# Node ID b2ff10e2fc12fe839781cb7ccd1d8d0302dd33f5
# Parent 35fa7c77c754aa4d156c42abfdb61ca178468872
convert: allow customizing git remote prefix
Previously all git remotes were created as "remote/foo". This patch adds a
configuration option for deciding what the prefix should be. This is useful if
you want the bookmarks to be "origin/foo" like they are in git, or if you're
integrating with the remotenames extension and don't want the local remote/foo
bookmarks to overlap with the remote foo bookmarks.
diff --git a/hgext/convert/__init__.py b/hgext/convert/__init__.py
--- a/hgext/convert/__init__.py
+++ b/hgext/convert/__init__.py
@@ -309,6 +309,10 @@ def convert(ui, src, dest=None, revmapfi
is very expensive for large projects, and is only effective when
``convert.git.similarity`` is greater than 0. The default is False.
+ :convert.git.remoteprefix: remote refs are converted as bookmarks with
+ ``convert.git.remoteprefix`` as a prefix followed by a /. The default
+ is 'remote'.
+
Perforce Source
###############
diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -376,8 +376,9 @@ class convert_git(converter_source):
prefixlen = len(prefix)
# factor two commands
- gitcmd = { 'remote/': 'git ls-remote --heads origin',
- '': 'git show-ref'}
+ remoteprefix = self.ui.config('convert', 'git.remoteprefix', 'remote')
+ gitcmd = { remoteprefix + '/': 'git ls-remote --heads origin',
+ '': 'git show-ref'}
# Origin heads
for reftype in gitcmd:
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
@@ -642,6 +642,30 @@ submodules)
$ hg -R git-repo6-hg tip -T "{file_dels}\n"
.hgsub .hgsubstate
+convert using a different remote prefix
+ $ git init git-repo7
+ Initialized empty Git repository in $TESTTMP/git-repo7/.git/
+ $ cd git-repo7
+ $ touch a && git add a && git commit -am "commit a"
+ [master (root-commit) 8ae5f69] commit a
+ Author: nottest <test at example.org>
+ 1 file changed, 0 insertions(+), 0 deletions(-)
+ create mode 100644 a
+ $ cd ..
+ $ git clone git-repo7 git-repo7-client
+ Cloning into 'git-repo7-client'...
+ done.
+ $ hg convert --config convert.git.remoteprefix=origin git-repo7-client hg-repo7
+ initializing destination hg-repo7 repository
+ scanning source...
+ sorting...
+ converting...
+ 0 commit a
+ updating bookmarks
+ $ hg -R hg-repo7 bookmarks
+ master 0:03bf38caa4c6
+ origin/master 0:03bf38caa4c6
+
damaged git repository tests:
In case the hard-coded hashes change, the following commands can be used to
list the hashes and their corresponding types in the repository:
diff --git a/tests/test-convert.t b/tests/test-convert.t
--- a/tests/test-convert.t
+++ b/tests/test-convert.t
@@ -259,6 +259,10 @@
for large projects, and is only effective when
"convert.git.similarity" is greater than 0. The default is
False.
+ convert.git.remoteprefix
+ remote refs are converted as bookmarks with
+ "convert.git.remoteprefix" as a prefix followed by a /. The
+ default is 'remote'.
Perforce Source
###############
More information about the Mercurial-devel
mailing list