{"thread":{"id":"35583","subject":"[PATCH] remote-hg: do not fail on invalid bookmarks","startedAt":"2013-12-29T11:30:02Z","lastAt":"2014-01-06T21:51:58Z","messageCount":7,"participants":["Antoine Pelisse","Mike Hommey","Junio C Hamano","Torsten Bögershausen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"232501","messageId":"1388316602-22443-1-git-send-email-apelisse@gmail.com","threadId":"35583","inReplyTo":null,"subject":"[PATCH] remote-hg: do not fail on invalid bookmarks","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-12-29T11:30:02Z","receivedAt":"2013-12-29T11:30:02Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?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\nSigned-off-by: Antoine Pelisse <apelisse@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex eb89ef6..12d850e 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -625,6 +625,9 @@ 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+            warn(\"Ignoring invalid bookmark '%s'\", bmark)\n+            continue\n         bmarks[bmark] = repo[node]\n \n     cur = repo.dirstate.branch()\n-- \n1.8.5.1.97.g8d784da.dirty\n"},{"id":"232502","messageId":"20131229222433.GA31355@glandium.org","threadId":"35583","inReplyTo":"1388316602-22443-1-git-send-email-apelisse@gmail.com","subject":"Re: [PATCH] remote-hg: do not fail on invalid bookmarks","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2013-12-29T22:24:33Z","receivedAt":"2013-12-29T22:24:33Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Sun, Dec 29, 2013 at 12:30:02PM +0100, Antoine Pelisse wrote:\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\nIt's not invalid, it's used to indicate deleted bookmarks. (Tags have\nthe same property)\n\nMike\n"},{"id":"232504","messageId":"CALWbr2wYqxdMhaWfXQCOk3J_Mxy6=NcScyg9-__j8PPdhY7reA@mail.gmail.com","threadId":"35583","inReplyTo":"20131229222433.GA31355@glandium.org","subject":"Re: [PATCH] remote-hg: do not fail on invalid bookmarks","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-12-30T07:41:13Z","receivedAt":"2013-12-30T07:41:13Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"On Sun, Dec 29, 2013 at 11:24 PM, Mike Hommey <mh@glandium.org> wrote:\n> On Sun, Dec 29, 2013 at 12:30:02PM +0100, Antoine Pelisse wrote:\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>\n> It's not invalid, it's used to indicate deleted bookmarks. (Tags have\n> the same property)\n\nHey Mike,\nIndeed, I don't know how I ended-up with such a bookmark, but it\nprevented me from git-cloning the repository (and the backtrace was\nnot very helpful at first).\nBut I'm still not sure what you mean by \"deleted bookmarks\" ?\nI guess it's not \"hg bookmark --delete\", as it would not be listed at\nall. Is it \"hg strip some_changeset\" that end-up deleting the\nbookmarked changeset ? I think I've tested this use-case and it moved\nthe bookmark to a parent changeset.\n\nAntoine,\n"},{"id":"232519","messageId":"xmqqha9qrw4s.fsf@gitster.dls.corp.google.com","threadId":"35583","inReplyTo":"20131229222433.GA31355@glandium.org","subject":"Re: [PATCH] remote-hg: do not fail on invalid bookmarks","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-30T19:12:19Z","receivedAt":"2013-12-30T19:12:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Hommey <mh@glandium.org> writes:\n\n> On Sun, Dec 29, 2013 at 12:30:02PM +0100, Antoine Pelisse wrote:\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>\n> It's not invalid, it's used to indicate deleted bookmarks. (Tags have\n> the same property)\n\nSo what should remote-hg behave in such a case, other than what\nAntoine's change does (which is to, IIRC, warn, ignore and\ncontinue).\n"},{"id":"232534","messageId":"20131230232239.GA5688@glandium.org","threadId":"35583","inReplyTo":"CALWbr2wYqxdMhaWfXQCOk3J_Mxy6=NcScyg9-__j8PPdhY7reA@mail.gmail.com","subject":"Re: [PATCH] remote-hg: do not fail on invalid bookmarks","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2013-12-30T23:22:39Z","receivedAt":"2013-12-30T23:22:39Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Mon, Dec 30, 2013 at 08:41:13AM +0100, Antoine Pelisse wrote:\n> On Sun, Dec 29, 2013 at 11:24 PM, Mike Hommey <mh@glandium.org> wrote:\n> > On Sun, Dec 29, 2013 at 12:30:02PM +0100, Antoine Pelisse wrote:\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> >\n> > It's not invalid, it's used to indicate deleted bookmarks. (Tags have\n> > the same property)\n> \n> Hey Mike,\n> Indeed, I don't know how I ended-up with such a bookmark, but it\n> prevented me from git-cloning the repository (and the backtrace was\n> not very helpful at first).\n> But I'm still not sure what you mean by \"deleted bookmarks\" ?\n> I guess it's not \"hg bookmark --delete\", as it would not be listed at\n> all. Is it \"hg strip some_changeset\" that end-up deleting the\n> bookmarked changeset ? I think I've tested this use-case and it moved\n> the bookmark to a parent changeset.\n\nMmmm after looking at the mercurial code, it looks like i was wrong and\nbookmarks are not handled like tags. You can actually create such a\nbookmark on purpose with:\n\n$ hg bookmark -r null foo\n\nThen, if you do, say:\n\n$ hg up -r foo\n$ echo a > a\n$ hg add a\n$ hg commit -m a\n\nThen you end up with a completely new head with no ancestors in common\nwith the others.\n\nIn git terms,\n\n$ hg bookmark -r null foo\n$ hg up -r foo\n\nis equivalent to\n\n$ git checkout --orphan foo\n\nBut git never creates an actual ref in that case.\n\nMike\n"},{"id":"232706","messageId":"52CAB508.5010002@web.de","threadId":"35583","inReplyTo":"1388316602-22443-1-git-send-email-apelisse@gmail.com","subject":"Re: [PATCH] remote-hg: do not fail on invalid bookmarks","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-01-06T13:52:08Z","receivedAt":"2014-01-06T13:52:08Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2013-12-29 12.30, Antoine Pelisse wrote:\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> \n> Signed-off-by: Antoine Pelisse <apelisse@gmail.com>\n> ---\n>  contrib/remote-helpers/git-remote-hg | 3 +++\n>  1 file changed, 3 insertions(+)\n> \n> diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\n> index eb89ef6..12d850e 100755\n> --- a/contrib/remote-helpers/git-remote-hg\n> +++ b/contrib/remote-helpers/git-remote-hg\n> @@ -625,6 +625,9 @@ 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> +            warn(\"Ignoring invalid bookmark '%s'\", bmark)\n> +            continue\n>          bmarks[bmark] = repo[node]\n>  \n>      cur = repo.dirstate.branch()\n> \n(Side note: ap/remote-hg-skip-null-bookmarks)\n\nWhen I run the test-suite like this:\n~/projects/git/git.pu/contrib/remote-helpers$ debug=t verbose=t make test-hg-hg-git.sh\n\nAll 11 test cases fail on my systems (Debian Wheezy and Mac OS X):\n[snip]\nWARNING: Ignoring invalid bookmark 'master'\nTo hg::../hgrepo-git\n ! [remote rejected] master -> master\nerror: failed to push some refs to 'hg::../hgrepo-git'\nnot ok 1 - executable bit\n#\t\n[snip]\n"},{"id":"232770","messageId":"CALWbr2zC-Q8YduW9b1feThBtz38Tsk7D1BoCRd7KxnCuht27PQ@mail.gmail.com","threadId":"35583","inReplyTo":"52CAB508.5010002@web.de","subject":"Re: [PATCH] remote-hg: do not fail on invalid bookmarks","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2014-01-06T21:51:58Z","receivedAt":"2014-01-06T21:51:58Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"Thanks for noticing,\nI can reproduce at work, I will try to come-up with an improved version soon,\n\nCheers,\nAntoine\n\nOn Mon, Jan 6, 2014 at 2:52 PM, Torsten Bögershausen <tboegi@web.de> wrote:\n> On 2013-12-29 12.30, Antoine Pelisse wrote:\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>>\n>> Signed-off-by: Antoine Pelisse <apelisse@gmail.com>\n>> ---\n>>  contrib/remote-helpers/git-remote-hg | 3 +++\n>>  1 file changed, 3 insertions(+)\n>>\n>> diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\n>> index eb89ef6..12d850e 100755\n>> --- a/contrib/remote-helpers/git-remote-hg\n>> +++ b/contrib/remote-helpers/git-remote-hg\n>> @@ -625,6 +625,9 @@ 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>> +            warn(\"Ignoring invalid bookmark '%s'\", bmark)\n>> +            continue\n>>          bmarks[bmark] = repo[node]\n>>\n>>      cur = repo.dirstate.branch()\n>>\n> (Side note: ap/remote-hg-skip-null-bookmarks)\n>\n> When I run the test-suite like this:\n> ~/projects/git/git.pu/contrib/remote-helpers$ debug=t verbose=t make test-hg-hg-git.sh\n>\n> All 11 test cases fail on my systems (Debian Wheezy and Mac OS X):\n> [snip]\n> WARNING: Ignoring invalid bookmark 'master'\n> To hg::../hgrepo-git\n>  ! [remote rejected] master -> master\n> error: failed to push some refs to 'hg::../hgrepo-git'\n> not ok 1 - executable bit\n> #\n> [snip]\n>\n>\n"}]}