summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMax Horn <max@quendi.de>2014-03-21 11:36:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-03-25 19:05:24 (GMT)
commit51be46ec4d0b64c1deb60a4814bcd24b6b478eeb (patch)
tree95a7dea28e97d7c03bb4b83de2ba2a561b171322 /contrib
parentd2446dfd7f3b3f8948142cfb07a0270e2497d93f (diff)
downloadgit-51be46ec4d0b64c1deb60a4814bcd24b6b478eeb.zip
git-51be46ec4d0b64c1deb60a4814bcd24b6b478eeb.tar.gz
git-51be46ec4d0b64c1deb60a4814bcd24b6b478eeb.tar.bz2
remote-hg: do not fail on invalid bookmarks
Mercurial can have bookmarks pointing to "nullid" (the empty root revision), while Git can not have references to it. When cloning or fetching from a Mercurial repository that has such a bookmark, the import failed because git-remote-hg was not be able to create the corresponding reference. Warn the user about the invalid reference, and do not advertise these bookmarks as head refs, but otherwise continue the import. In particular, we still keep track of the fact that the remote repository has a bookmark of the given name, in case the user wants to modify that bookmark. Also add some test cases for this issue. Reported-by: Antoine Pelisse <apelisse@gmail.com> Signed-off-by: Max Horn <max@quendi.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg5
-rwxr-xr-xcontrib/remote-helpers/test-hg.sh73
2 files changed, 77 insertions, 1 deletions
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index c6026b9..61562b1 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -641,7 +641,10 @@ def do_list(parser):
print "? refs/heads/branches/%s" % gitref(branch)
for bmark in bmarks:
- print "? refs/heads/%s" % gitref(bmark)
+ if bmarks[bmark].hex() == '0000000000000000000000000000000000000000':
+ warn("Ignoring invalid bookmark '%s'", bmark)
+ else:
+ print "? refs/heads/%s" % gitref(bmark)
for tag, node in repo.tagslist():
if tag == 'tip':
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 72f745d..8834482 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -691,4 +691,77 @@ test_expect_success 'remote double failed push' '
)
'
+test_expect_success 'clone remote with master null bookmark, then push to the bookmark' '
+ test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+ hg init hgrepo &&
+ (
+ cd hgrepo &&
+ echo a >a &&
+ hg add a &&
+ hg commit -m a &&
+ hg bookmark -r null master
+ ) &&
+
+ git clone "hg::hgrepo" gitrepo &&
+ check gitrepo HEAD a &&
+ (
+ cd gitrepo &&
+ git checkout --quiet -b master &&
+ echo b >b &&
+ git add b &&
+ git commit -m b &&
+ git push origin master
+ )
+'
+
+test_expect_success 'clone remote with default null bookmark, then push to the bookmark' '
+ test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+ hg init hgrepo &&
+ (
+ cd hgrepo &&
+ echo a >a &&
+ hg add a &&
+ hg commit -m a &&
+ hg bookmark -r null -f default
+ ) &&
+
+ git clone "hg::hgrepo" gitrepo &&
+ check gitrepo HEAD a &&
+ (
+ cd gitrepo &&
+ git checkout --quiet -b default &&
+ echo b >b &&
+ git add b &&
+ git commit -m b &&
+ git push origin default
+ )
+'
+
+test_expect_success 'clone remote with generic null bookmark, then push to the bookmark' '
+ test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+ hg init hgrepo &&
+ (
+ cd hgrepo &&
+ echo a >a &&
+ hg add a &&
+ hg commit -m a &&
+ hg bookmark -r null bmark
+ ) &&
+
+ git clone "hg::hgrepo" gitrepo &&
+ check gitrepo HEAD a &&
+ (
+ cd gitrepo &&
+ git checkout --quiet -b bmark &&
+ git remote -v &&
+ echo b >b &&
+ git add b &&
+ git commit -m b &&
+ git push origin bmark
+ )
+'
+
test_done