threads / patch / 32091

patch, 4 partsremote-hg: small fixes

Subject: [PATCH 0/4] remote-hg: small fixes

## tl;dr

11 messages between Nov 12, 2012 and Nov 13, 2012. Diffs are folded; open one to read it.

replies: 10people: 3as markdown or json

Felipe Contreras· Nov 12, 2012, 17:41 UTC · lore
Hi,
Just a few fixes, nothing major.
Felipe Contreras (3):
  remote-hg: fix compatibility with older versions of hg
  remote-hg: try the 'tip' if no checkout present
  remote-hg: avoid bad refs
Ramkumar Ramachandra (1):
  remote-hg: add missing config for basic tests
 contrib/remote-helpers/git-remote-hg | 7 ++++++-
 contrib/remote-helpers/test-hg.sh    | 9 +++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
-- 
1.8.0
Felipe Contreras· Nov 12, 2012, 17:41 UTC · re: Felipe Contreras · lore

[PATCH 1/4] remote-hg: add missing config for basic tests

From: Ramkumar Ramachandra <artagnon@gmail.com>

'hg commit' fails otherwise in some versiosn of mercurial because of the missing user information. Other versions simply throw a warning and guess though.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/test-hg.sh | 9 +++++++++
 1 file changed, 9 insertions(+)
Show changes to contrib/remote-helpers/test-hg.sh +9 −0
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 40e6e3c..031dcbd 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -29,6 +29,15 @@ check () {
 	test_cmp expected actual
 }
 
+setup () {
+	(
+	echo "[ui]"
+	echo "username = A U Thor <author@example.com>"
+	) >> "$HOME"/.hgrc
+}
+
+setup
+
 test_expect_success 'cloning' '
   test_when_finished "rm -rf gitrepo*" &&
 
-- 
1.8.0
Jeff King· Nov 12, 2012, 20:32 UTC · re: Felipe Contreras · lore

Re: [PATCH 1/4] remote-hg: add missing config for basic tests

On Mon, Nov 12, 2012 at 06:41:05PM +0100, Felipe Contreras wrote:
> From: Ramkumar Ramachandra <artagnon@gmail.com>
> 
> 'hg commit' fails otherwise in some versiosn of mercurial because of
s/versiosn/versions/
Show 6 quoted lines
> +setup () {
> +	(
> +	echo "[ui]"
> +	echo "username = A U Thor <author@example.com>"
> +	) >> "$HOME"/.hgrc
> +}

This makes sense, but I wonder if we should use something different from the git author ident set up by the test scripts, just to double check that we do not have any bugs in confusing the two during the import.

Something like "H G Wells <wells@example.com>" would work, and satisfies my deep-seated desire for bad puns.

-Peff
Felipe Contreras· Nov 13, 2012, 03:46 UTC · re: Jeff King · lore

Re: [PATCH 1/4] remote-hg: add missing config for basic tests

On Mon, Nov 12, 2012 at 9:32 PM, Jeff King <peff@peff.net> wrote:
Show 18 quoted lines
> On Mon, Nov 12, 2012 at 06:41:05PM +0100, Felipe Contreras wrote:
>
>> From: Ramkumar Ramachandra <artagnon@gmail.com>
>>
>> 'hg commit' fails otherwise in some versiosn of mercurial because of
>
> s/versiosn/versions/
>
>> +setup () {
>> +     (
>> +     echo "[ui]"
>> +     echo "username = A U Thor <author@example.com>"
>> +     ) >> "$HOME"/.hgrc
>> +}
>
> This makes sense, but I wonder if we should use something different from
> the git author ident set up by the test scripts, just to double check
> that we do not have any bugs in confusing the two during the import.

I don't know, but these tests would not check for any of those issues. When such tests are added I would prefer the author to use to be explicitly defined, but lets see.

-- 
Felipe Contreras
Jeff King· Nov 13, 2012, 05:48 UTC · re: Felipe Contreras · lore

Re: [PATCH 1/4] remote-hg: add missing config for basic tests

On Tue, Nov 13, 2012 at 04:46:36AM +0100, Felipe Contreras wrote:
Show 14 quoted lines
> >> +setup () {
> >> +     (
> >> +     echo "[ui]"
> >> +     echo "username = A U Thor <author@example.com>"
> >> +     ) >> "$HOME"/.hgrc
> >> +}
> >
> > This makes sense, but I wonder if we should use something different from
> > the git author ident set up by the test scripts, just to double check
> > that we do not have any bugs in confusing the two during the import.
> 
> I don't know, but these tests would not check for any of those issues.
> When such tests are added I would prefer the author to use to be
> explicitly defined, but lets see.

It's OK if we do not add more explicit tests at this point. I'd just rather set a safer precedent on the off chance that it might catch something in a later test, just as we use separate GIT_AUTHOR_* and GIT_COMMITTER_* in the rest of the test suite. If the choice were not completely arbitrary and had some maintenance cost, I might be more concerned, but as far as I can tell, one name is as good as another at this point.

Any objection to me marking it up as I apply?
-Peff
Felipe Contreras· Nov 13, 2012, 07:12 UTC · re: Jeff King · lore

Re: [PATCH 1/4] remote-hg: add missing config for basic tests

On Tue, Nov 13, 2012 at 6:48 AM, Jeff King <peff@peff.net> wrote:
> Any objection to me marking it up as I apply?
Nope.
-- 
Felipe Contreras
Felipe Contreras· Nov 12, 2012, 17:41 UTC · re: Felipe Contreras · lore

[PATCH 2/4] remote-hg: fix compatibility with older versions of hg

Turns out repo.revs was introduced quite late, and it doesn't do anything fancy for our refspec; only list all the numbers in that range.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-hg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to contrib/remote-helpers/git-remote-hg +1 −1
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 1d46838..c6d0367 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -294,7 +294,7 @@ def export_ref(repo, name, kind, head):
     if tip and tip == head.rev():
         # nothing to do
         return
-    revs = repo.revs('%u:%u' % (tip, head))
+    revs = xrange(tip, head.rev() + 1)
     count = 0
 
     revs = [rev for rev in revs if not marks.is_marked(rev)]
-- 
1.8.0
Ramkumar Ramachandra· Nov 13, 2012, 05:25 UTC · re: Felipe Contreras · lore

Re: [PATCH 2/4] remote-hg: fix compatibility with older versions of hg

This patch fixes my original problem. So,
Reported-by: Ramkumar Ramachandra <artagnon@gmail.com>
Tested-by: Ramkumar Ramachandra <artagnon@gmail.com>
However, test 4 in test-hg.sh still fails for me:

--- expected 2012-11-13 05:22:57.946637384 +0000 +++ actual 2012-11-13 05:22:57.946637384 +0000

Show changes to diff +2 −2
@@ -1,2 +1,2 @@
-zero
-refs/heads/master
+feature-a
+refs/heads/feature-a

What is going on?

Ram
Felipe Contreras· Nov 13, 2012, 07:11 UTC · re: Ramkumar Ramachandra · lore

Re: [PATCH 2/4] remote-hg: fix compatibility with older versions of hg

On Tue, Nov 13, 2012 at 6:25 AM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:

Show 15 quoted lines
> This patch fixes my original problem. So,
> Reported-by: Ramkumar Ramachandra <artagnon@gmail.com>
> Tested-by: Ramkumar Ramachandra <artagnon@gmail.com>
>
> However, test 4 in test-hg.sh still fails for me:
>
> --- expected    2012-11-13 05:22:57.946637384 +0000
> +++ actual      2012-11-13 05:22:57.946637384 +0000
> @@ -1,2 +1,2 @@
> -zero
> -refs/heads/master
> +feature-a
> +refs/heads/feature-a
>
> What is going on?
Probably a bug in mercurial, but can be worked around:
Show changes to contrib/remote-helpers/git-remote-hg +9 −1
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -429,10 +429,18 @@ def get_branch_tip(repo, branch):

     return heads[0]

+def get_current_bookmark(repo):
+    head = bookmarks.readcurrent(repo)
+    if not head:
+        return None
+    if repo[head] != repo['.']:
+        return None
+    return head
+
 def list_head(repo, cur):
     global g_head, bmarks

-    head = bookmarks.readcurrent(repo)
+    head = get_current_bookmark(repo)
     if head:
         node = repo[head]
     else:
-- 
Felipe Contreras
Felipe Contreras· Nov 12, 2012, 17:41 UTC · re: Felipe Contreras · lore

[PATCH 3/4] remote-hg: try the 'tip' if no checkout present

There's no concept of HEAD in mercurial, but let's try our best to do something sensible.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-hg | 2 ++
 1 file changed, 2 insertions(+)
Show changes to contrib/remote-helpers/git-remote-hg +2 −0
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index c6d0367..3cdc1e2 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -440,6 +440,8 @@ def list_head(repo, cur):
         head = cur
         node = repo['.']
         if not node:
+            node = repo['tip']
+        if not node:
             return
         if head == 'default':
             head = 'master'
-- 
1.8.0
Felipe Contreras· Nov 12, 2012, 17:41 UTC · re: Felipe Contreras · lore

[PATCH 4/4] remote-hg: avoid bad refs

Turns out fast-export throws bad 'reset' commands because of a behavior in transport-helper that is not even needed.

Either way, better to ignore them, otherwise the user will get warnings when we OK them.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-hg | 3 +++
 1 file changed, 3 insertions(+)
Show changes to contrib/remote-helpers/git-remote-hg +3 −0
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 3cdc1e2..48f8f5d 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -704,6 +704,9 @@ def do_export(parser):
         elif ref.startswith('refs/tags/'):
             tag = ref[len('refs/tags/'):]
             parser.repo.tag([tag], node, None, True, None, {})
+        else:
+            # transport-helper/fast-export bugs
+            continue
         print "ok %s" % ref
 
     print
-- 
1.8.0

← back to recent threads