{"thread":{"id":"36237","subject":"[PATCH v2] remote-hg: do not fail on invalid bookmarks","startedAt":"2014-03-19T21:42:46Z","lastAt":"2014-03-19T21:51:37Z","messageCount":2,"participants":["Max Horn","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"237123","messageId":"1395265366-85650-1-git-send-email-max@quendi.de","threadId":"36237","inReplyTo":null,"subject":"[PATCH v2] remote-hg: do not fail on invalid bookmarks","fromName":"Max Horn","fromEmail":"max@quendi.de","sentAt":"2014-03-19T21:42:46Z","receivedAt":"2014-03-19T21:42:46Z","isPatch":true,"sender":{"key":"max@quendi.de","avatar":"https://avatars.githubusercontent.com/u/241512?v=4"},"body":"Mercurial can have bookmarks pointing to \"nullid\" (the empty root\nrevision), while Git can not have references to it.\nWhen cloning or fetching from a Mercurial repository that has such a\nbookmark, the import will fail because git-remote-hg will not be able to\ncreate the corresponding reference.\n\nWarn the user about the invalid reference, and continue the import,\ninstead of stopping right away.\n\nAlso add some test cases for this issue.\n\nReported-by: Antoine Pelisse <apelisse@gmail.com>\nSigned-off-by: Max Horn <max@quendi.de>\n---\n contrib/remote-helpers/git-remote-hg |  6 +++++\n contrib/remote-helpers/test-hg.sh    | 48 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 54 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex eb89ef6..49b2c2e 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -625,6 +625,12 @@ def list_head(repo, cur):\n def do_list(parser):\n     repo = parser.repo\n     for bmark, node in bookmarks.listbookmarks(repo).iteritems():\n+        if node == '0000000000000000000000000000000000000000':\n+            if fake_bmark == 'default' and bmark == 'master':\n+                pass\n+            else:\n+                warn(\"Ignoring invalid bookmark '%s'\", bmark)\n+                continue\n         bmarks[bmark] = repo[node]\n \n     cur = repo.dirstate.branch()\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex a933b1e..8d01b32 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -772,4 +772,52 @@ test_expect_success 'remote double failed push' '\n \t)\n '\n \n+test_expect_success 'clone remote with master null bookmark' '\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\techo a >a &&\n+\thg add a &&\n+\thg commit -m a &&\n+\thg bookmark -r null master\n+\t) &&\n+\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcheck gitrepo HEAD a\n+'\n+\n+test_expect_success 'clone remote with default null bookmark' '\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\techo a >a &&\n+\thg add a &&\n+\thg commit -m a &&\n+\thg bookmark -r null -f default\n+\t) &&\n+\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcheck gitrepo HEAD a\n+'\n+\n+test_expect_success 'clone remote with generic null bookmark' '\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\techo a >a &&\n+\thg add a &&\n+\thg commit -m a &&\n+\thg bookmark -r null bmark\n+\t) &&\n+\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcheck gitrepo HEAD a\n+'\n+\n test_done\n-- \n1.9.0.7.ga299b13\n"},{"id":"237124","messageId":"xmqqpplh26xi.fsf@gitster.dls.corp.google.com","threadId":"36237","inReplyTo":"1395265366-85650-1-git-send-email-max@quendi.de","subject":"Re: [PATCH v2] remote-hg: do not fail on invalid bookmarks","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-03-19T21:51:37Z","receivedAt":"2014-03-19T21:51:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Max Horn <max@quendi.de> writes:\n\n> Mercurial can have bookmarks pointing to \"nullid\" (the empty root\n> revision), while Git can not have references to it.\n> When cloning or fetching from a Mercurial repository that has such a\n> bookmark, the import will fail because git-remote-hg will not be able to\n> create the corresponding reference.\n>\n> Warn the user about the invalid reference, and continue the import,\n> instead of stopping right away.\n\nThe text above is identical to what Antoine wrote in e8d48743\n(remote-hg: do not fail on invalid bookmarks, 2013-12-29); I'd\nassume that this is to replace it.\n\nBut the code seems to do more, and I think that is related to the\ndetailed analysis you dug up from the archive earlier and then\nsummarised in your $gmane/244440.  Can you say a bit more about\nthese fake-bmark and bmark checking like you did in that original\n3-patch series?\n\nThanks.\n\n> Also add some test cases for this issue.\n>\n> Reported-by: Antoine Pelisse <apelisse@gmail.com>\n> Signed-off-by: Max Horn <max@quendi.de>\n> ---\n>  contrib/remote-helpers/git-remote-hg |  6 +++++\n>  contrib/remote-helpers/test-hg.sh    | 48 ++++++++++++++++++++++++++++++++++++\n>  2 files changed, 54 insertions(+)\n>\n> diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\n> index eb89ef6..49b2c2e 100755\n> --- a/contrib/remote-helpers/git-remote-hg\n> +++ b/contrib/remote-helpers/git-remote-hg\n> @@ -625,6 +625,12 @@ def list_head(repo, cur):\n>  def do_list(parser):\n>      repo = parser.repo\n>      for bmark, node in bookmarks.listbookmarks(repo).iteritems():\n> +        if node == '0000000000000000000000000000000000000000':\n> +            if fake_bmark == 'default' and bmark == 'master':\n> +                pass\n> +            else:\n> +                warn(\"Ignoring invalid bookmark '%s'\", bmark)\n> +                continue\n>          bmarks[bmark] = repo[node]\n>  \n>      cur = repo.dirstate.branch()\n> diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\n> index a933b1e..8d01b32 100755\n> --- a/contrib/remote-helpers/test-hg.sh\n> +++ b/contrib/remote-helpers/test-hg.sh\n> @@ -772,4 +772,52 @@ test_expect_success 'remote double failed push' '\n>  \t)\n>  '\n>  \n> +test_expect_success 'clone remote with master null bookmark' '\n> +\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n> +\n> +\t(\n> +\thg init hgrepo &&\n> +\tcd hgrepo &&\n> +\techo a >a &&\n> +\thg add a &&\n> +\thg commit -m a &&\n> +\thg bookmark -r null master\n> +\t) &&\n> +\n> +\tgit clone \"hg::hgrepo\" gitrepo &&\n> +\tcheck gitrepo HEAD a\n> +'\n> +\n> +test_expect_success 'clone remote with default null bookmark' '\n> +\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n> +\n> +\t(\n> +\thg init hgrepo &&\n> +\tcd hgrepo &&\n> +\techo a >a &&\n> +\thg add a &&\n> +\thg commit -m a &&\n> +\thg bookmark -r null -f default\n> +\t) &&\n> +\n> +\tgit clone \"hg::hgrepo\" gitrepo &&\n> +\tcheck gitrepo HEAD a\n> +'\n> +\n> +test_expect_success 'clone remote with generic null bookmark' '\n> +\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n> +\n> +\t(\n> +\thg init hgrepo &&\n> +\tcd hgrepo &&\n> +\techo a >a &&\n> +\thg add a &&\n> +\thg commit -m a &&\n> +\thg bookmark -r null bmark\n> +\t) &&\n> +\n> +\tgit clone \"hg::hgrepo\" gitrepo &&\n> +\tcheck gitrepo HEAD a\n> +'\n> +\n>  test_done\n"}]}