From: "Torsten Bögershausen" <tboegi@web.de>
To: Max Horn <max@quendi.de>, git@vger.kernel.org
Cc: Antoine Pelisse <apelisse@gmail.com>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3] remote-hg: do not fail on invalid bookmarks
Date: Fri, 21 Mar 2014 21:47:19 +0100 [thread overview]
Message-ID: <532CA557.20007@web.de> (raw)
In-Reply-To: <A4F451CA-D1DE-43A9-A4DA-23594C08C4DD@quendi.de>
On 2014-03-21 12.36, Max Horn wrote:
All tests passed :-), thanks from my side.
comments inline, some are debatable
> 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.
s/some test cases/test cases/
>
> Reported-by: Antoine Pelisse <apelisse@gmail.com>
> Signed-off-by: Max Horn <max@quendi.de>
> ---
> This is a different fix than in my previous attempts. I thought
> a bit more about the issue, and determined that the previous fix,
> while working, was not really correct: It is wrong to
> treat nullid bookmarks as if they are non-existent; if e.g.
> the user wants to modify the bookmark from git, we need to
> into account that the remote already has a bookmark with that name.
> Indeed, I extended the new test cases to cover this aspect.
> With the previous fix, the new tests would fail upon pushing,
> with the new one, they work.
>
> contrib/remote-helpers/git-remote-hg | 5 ++-
> contrib/remote-helpers/test-hg.sh | 67 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 71 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
> index eb89ef6..36b5261 100755
> --- a/contrib/remote-helpers/git-remote-hg
> +++ b/contrib/remote-helpers/git-remote-hg
> @@ -643,7 +643,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 a933b1e..f5d0d97 100755
> --- a/contrib/remote-helpers/test-hg.sh
> +++ b/contrib/remote-helpers/test-hg.sh
> @@ -772,4 +772,71 @@ 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 &&
Minor:
We can change the order here, to make the "cd hgrepo" the first line in the subshell:
+ 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 &&
And here we do "cd", and this should be done in a subshell
> + 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 &&
(Same minor as above)
> + 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 &&
(Same as above)
> + 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 &&
Sub-shell missing
> + git checkout --quiet -b bmark &&
> + git remote -v &&
> + echo b >b &&
> + git add b &&
> + git commit -m b &&
> + git push origin bmark
> +'
> +
> test_done
next prev parent reply other threads:[~2014-03-21 20:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-21 11:36 [PATCH v3] remote-hg: do not fail on invalid bookmarks Max Horn
2014-03-21 20:47 ` Torsten Bögershausen [this message]
2014-03-21 21:44 ` Max Horn
2014-03-21 22:32 ` Junio C Hamano
2014-03-22 16:41 ` Torsten Bögershausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=532CA557.20007@web.de \
--to=tboegi@web.de \
--cc=apelisse@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=max@quendi.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).