Skip to content

Commit 125d8ec

Browse files
committed
Merge branch 'ap/remote-hg-skip-null-bookmarks'
* ap/remote-hg-skip-null-bookmarks: remote-hg: do not fail on invalid bookmarks
2 parents 8132f2c + 51be46e commit 125d8ec

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,10 @@ def do_list(parser):
643643
print "? refs/heads/branches/%s" % gitref(branch)
644644

645645
for bmark in bmarks:
646-
print "? refs/heads/%s" % gitref(bmark)
646+
if bmarks[bmark].hex() == '0000000000000000000000000000000000000000':
647+
warn("Ignoring invalid bookmark '%s'", bmark)
648+
else:
649+
print "? refs/heads/%s" % gitref(bmark)
647650

648651
for tag, node in repo.tagslist():
649652
if tag == 'tip':

contrib/remote-helpers/test-hg.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,4 +772,77 @@ test_expect_success 'remote double failed push' '
772772
)
773773
'
774774

775+
test_expect_success 'clone remote with master null bookmark, then push to the bookmark' '
776+
test_when_finished "rm -rf gitrepo* hgrepo*" &&
777+
778+
hg init hgrepo &&
779+
(
780+
cd hgrepo &&
781+
echo a >a &&
782+
hg add a &&
783+
hg commit -m a &&
784+
hg bookmark -r null master
785+
) &&
786+
787+
git clone "hg::hgrepo" gitrepo &&
788+
check gitrepo HEAD a &&
789+
(
790+
cd gitrepo &&
791+
git checkout --quiet -b master &&
792+
echo b >b &&
793+
git add b &&
794+
git commit -m b &&
795+
git push origin master
796+
)
797+
'
798+
799+
test_expect_success 'clone remote with default null bookmark, then push to the bookmark' '
800+
test_when_finished "rm -rf gitrepo* hgrepo*" &&
801+
802+
hg init hgrepo &&
803+
(
804+
cd hgrepo &&
805+
echo a >a &&
806+
hg add a &&
807+
hg commit -m a &&
808+
hg bookmark -r null -f default
809+
) &&
810+
811+
git clone "hg::hgrepo" gitrepo &&
812+
check gitrepo HEAD a &&
813+
(
814+
cd gitrepo &&
815+
git checkout --quiet -b default &&
816+
echo b >b &&
817+
git add b &&
818+
git commit -m b &&
819+
git push origin default
820+
)
821+
'
822+
823+
test_expect_success 'clone remote with generic null bookmark, then push to the bookmark' '
824+
test_when_finished "rm -rf gitrepo* hgrepo*" &&
825+
826+
hg init hgrepo &&
827+
(
828+
cd hgrepo &&
829+
echo a >a &&
830+
hg add a &&
831+
hg commit -m a &&
832+
hg bookmark -r null bmark
833+
) &&
834+
835+
git clone "hg::hgrepo" gitrepo &&
836+
check gitrepo HEAD a &&
837+
(
838+
cd gitrepo &&
839+
git checkout --quiet -b bmark &&
840+
git remote -v &&
841+
echo b >b &&
842+
git add b &&
843+
git commit -m b &&
844+
git push origin bmark
845+
)
846+
'
847+
775848
test_done

0 commit comments

Comments
 (0)