From 1c7261783155a7e63d694e7994da3bc3130b1c8a Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 21 Mar 2014 12:36:36 +0100 Subject: [PATCH] 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. 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. Reported-by: Antoine Pelisse Signed-off-by: Max Horn Signed-off-by: Junio C Hamano Signed-off-by: Felipe Contreras --- git-remote-hg | 5 ++++- test/main.t | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/git-remote-hg b/git-remote-hg index 3c79daf..35f469a 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -648,7 +648,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() == '0' * 40: + 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/test/main.t b/test/main.t index b8625ca..22c82f6 100755 --- a/test/main.t +++ b/test/main.t @@ -773,4 +773,29 @@ test_expect_success 'remote double failed push' ' ) ' +test_expect_success 'clone remote with null bookmark, then push' ' + 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 bookmark + ) && + + ( + git clone "hg::hgrepo" gitrepo && + check gitrepo HEAD a && + cd gitrepo && + git checkout --quiet -b bookmark && + git remote -v && + echo b > b && + git add b && + git commit -m b && + git push origin bookmark + ) +' + test_done