Patchwork [2,of,2,STABLE] transplant: only pull the transplanted revision (issue4692)

login
register
mail settings
Submitter Pierre-Yves David
Date June 30, 2015, 3:23 a.m.
Message ID <51b43d13ca85b1ae8780.1435634607@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9828/
State Accepted
Headers show

Comments

Pierre-Yves David - June 30, 2015, 3:23 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1435630182 25200
#      Mon Jun 29 19:09:42 2015 -0700
# Branch stable
# Node ID 51b43d13ca85b1ae878070665f350d11110ee19f
# Parent  15372dd37cf6e6b9a4892a40525a99b004419d47
transplant: only pull the transplanted revision (issue4692)

For some reason, transplant was pulling all remote revisions when transplanting
from a remote repository (unless --branch was
specified).
Matt Mackall - June 30, 2015, 6:38 p.m.
On Mon, 2015-06-29 at 20:23 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1435630182 25200
> #      Mon Jun 29 19:09:42 2015 -0700
> # Branch stable
> # Node ID 51b43d13ca85b1ae878070665f350d11110ee19f
> # Parent  15372dd37cf6e6b9a4892a40525a99b004419d47
> transplant: only pull the transplanted revision (issue4692)

These are queued for stable, thanks. Congratulations on becoming the
transplant maintainer!

Patch

diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -623,12 +623,18 @@  def transplant(ui, repo, *revs, **opts):
 
     sourcerepo = opts.get('source')
     if sourcerepo:
         peer = hg.peer(repo, opts, ui.expandpath(sourcerepo))
         heads = map(peer.lookup, opts.get('branch', ()))
+        target = set(heads)
+        for r in revs:
+            try:
+                target.add(peer.lookup(r))
+            except error.RepoError:
+                pass
         source, csets, cleanupfn = bundlerepo.getremotechanges(ui, repo, peer,
-                                    onlyheads=heads, force=True)
+                                    onlyheads=sorted(target), force=True)
     else:
         source = repo
         heads = map(source.lookup, opts.get('branch', ()))
         cleanupfn = None
 
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -311,17 +311,15 @@  remote transplant with pull
   2  b3
   1  b1
   0  r1
 
 remote transplant without pull
-(I'm pretty sure this test is actually pulling,
-It was using "2" and "4" (as the previous transplant used to) which referenced
+(It was using "2" and "4" (as the previous transplant used to) which referenced
 revision different from on run to another)
 
   $ hg pull -q http://localhost:$HGPORT/
   $ hg transplant -s http://localhost:$HGPORT/ 8d9279348abb 722f4667af76
-  searching for changes
   skipping already applied revision 2:8d9279348abb
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
 transplant --continue