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

Stanislau Hlebik stash at fb.com
Mon Jan 30 10:56:00 EST 2017


# HG changeset patch
# User Stanislau Hlebik <stash at 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.

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


More information about the Mercurial-devel mailing list