Patchwork [STABLE] transplant: use peer of source repository as "remote" for "repo.pull()"

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 16, 2013, 2:15 p.m.
Message ID <f72c10f05a7ed883f92e.1384611355@juju>
Download mbox | patch
Permalink /patch/2991/
State Accepted
Commit 6fb59247c7d5cb763ad28f8a2785171108b4db47
Headers show

Comments

Katsunori FUJIWARA - Nov. 16, 2013, 2:15 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1384611260 -32400
#      Sat Nov 16 23:14:20 2013 +0900
# Node ID f72c10f05a7ed883f92efa2b06dab050d2f6530c
# Parent  c38c3fdc8b9317ba09e03ab09364c3800da7c50c
transplant: use peer of source repository as "remote" for "repo.pull()"

Before this patch, transplant with "--merge" option fails with
traceback unexpectedly, if it causes pull from the source repository
on the local host.

"discovery.findcommonincoming()" invokes "capable()" method on the
object given from "localrepository.pull()", but it is
"localrepository" object in this case and doesn't have such method.

This patch uses peer object of source repository as "remote" argument
for "localrepository.pull()" invocation like other invocations of it
in transplant.py.
Augie Fackler - Nov. 16, 2013, 5:35 p.m.
On Sat, Nov 16, 2013 at 11:15:55PM +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1384611260 -32400
> #      Sat Nov 16 23:14:20 2013 +0900
> # Node ID f72c10f05a7ed883f92efa2b06dab050d2f6530c
> # Parent  c38c3fdc8b9317ba09e03ab09364c3800da7c50c
> transplant: use peer of source repository as "remote" for "repo.pull()"

queued, thanks


>
> Before this patch, transplant with "--merge" option fails with
> traceback unexpectedly, if it causes pull from the source repository
> on the local host.
>
> "discovery.findcommonincoming()" invokes "capable()" method on the
> object given from "localrepository.pull()", but it is
> "localrepository" object in this case and doesn't have such method.
>
> This patch uses peer object of source repository as "remote" argument
> for "localrepository.pull()" invocation like other invocations of it
> in transplant.py.
>
> diff --git a/hgext/transplant.py b/hgext/transplant.py
> --- a/hgext/transplant.py
> +++ b/hgext/transplant.py
> @@ -154,7 +154,7 @@
>                      # transplants before them fail.
>                      domerge = True
>                      if not hasnode(repo, node):
> -                        repo.pull(source, heads=[node])
> +                        repo.pull(source.peer(), heads=[node])
>
>                  skipmerge = False
>                  if parents[1] != revlog.nullid:
> diff --git a/tests/test-transplant.t b/tests/test-transplant.t
> --- a/tests/test-transplant.t
> +++ b/tests/test-transplant.t
> @@ -430,6 +430,20 @@
>    adding manifests
>    adding file changes
>    added 4 changesets with 4 changes to 4 files
> +
> +test "--merge" causing pull from source repository on local host
> +
> +  $ hg --config extensions.mq= -q strip 2
> +  $ hg transplant -s ../t --merge tip
> +  searching for changes
> +  searching for changes
> +  adding changesets
> +  adding manifests
> +  adding file changes
> +  added 2 changesets with 2 changes to 2 files
> +  applying a53251cdf717
> +  4:a53251cdf717 merged at 4831f4dc831a
> +
>    $ cd ..
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -154,7 +154,7 @@ 
                     # transplants before them fail.
                     domerge = True
                     if not hasnode(repo, node):
-                        repo.pull(source, heads=[node])
+                        repo.pull(source.peer(), heads=[node])
 
                 skipmerge = False
                 if parents[1] != revlog.nullid:
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -430,6 +430,20 @@ 
   adding manifests
   adding file changes
   added 4 changesets with 4 changes to 4 files
+
+test "--merge" causing pull from source repository on local host
+
+  $ hg --config extensions.mq= -q strip 2
+  $ hg transplant -s ../t --merge tip
+  searching for changes
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files
+  applying a53251cdf717
+  4:a53251cdf717 merged at 4831f4dc831a
+
   $ cd ..