Patchwork [2,of,6,remotenames-ext] selectivepull: fix passing `heads` argument multiple times

login
register
mail settings
Submitter Stanislau Hlebik
Date Jan. 30, 2017, 3:56 p.m.
Message ID <a7786a178d5cb9abed98.1485791760@devvm1840.lla2.facebook.com>
Download mbox | patch
Permalink /patch/18277/
State Accepted
Headers show

Comments

Stanislau Hlebik - Jan. 30, 2017, 3:56 p.m.
# HG changeset patch
# User Stanislau Hlebik <stash@fb.com>
# Date 1485791608 28800
#      Mon Jan 30 07:53:28 2017 -0800
# Node ID a7786a178d5cb9abed981c76e47588fffede7511
# Parent  8b66569e49ce6382670497aa4e96c5e81c224439
selectivepull: fix passing `heads` argument multiple times

Usually `heads` are passed using kwargs but sometimes they are passed using
args (for example, during clone). In this case we set in kwargs and args
and orig call fails. This patch fixes it.

Also change the tests to cover this behaviour.

Patch

diff --git a/remotenames.py b/remotenames.py
--- a/remotenames.py
+++ b/remotenames.py
@@ -133,6 +133,11 @@ 
                 bookmarks[bookmark] = remotebookmarks[bookmark]
         else:
             heads = kwargs.get('heads') or []
+            # heads may be passed as positional args
+            if len(args) > 0:
+                if args[0]:
+                    heads = args[0]
+                args = args[1:]
             for bookmark in bookmarks:
                 heads.append(remote.lookup(remotebookmarks[bookmark]))
             kwargs['bookmarks'] = bookmarks
diff --git a/tests/test-selective-pull.t b/tests/test-selective-pull.t
--- a/tests/test-selective-pull.t
+++ b/tests/test-selective-pull.t
@@ -97,7 +97,7 @@ 
 
 Create second remote
   $ cd ..
-  $ hg clone -q remoterepo secondremoterepo
+  $ hg clone -q ssh://user@dummy/remoterepo secondremoterepo
   $ cd secondremoterepo
   $ hg up -q 0238718db2b1
   $ hg book master