File hg-convert_allow_customizing_git_remote_prefix.patch of Package mercurial.4928
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1436848666 25200
# Mon Jul 13 21:37:46 2015 -0700
# Node ID d9133e89d39decf425ddf9fcec3a62fb5f5b8bbf
# 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.
---
hgext/convert/__init__.py | 4 ++++
hgext/convert/git.py | 5 +++--
tests/test-convert-git.t | 24 ++++++++++++++++++++++++
3 files changed, 31 insertions(+), 2 deletions(-)
--- a/hgext/convert/__init__.py
+++ b/hgext/convert/__init__.py
@@ -249,6 +249,10 @@ def convert(ui, src, dest=None, revmapfi
:convert.svn.startrev: specify start Subversion revision number.
The default is 0.
+ :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
###############
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -278,8 +278,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:
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -364,6 +364,30 @@ convert sub modules
$ cd ../..
+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@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: