push: move `newbranch` argument into the push object
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 30 Jan 2014 17:08:29 -0800
changeset 20351 c05ad450df23
parent 20350 8c85d968ee65
child 20352 58300f61b139
push: move `newbranch` argument into the push object One more step toward a more modular push function.
mercurial/exchange.py
--- a/mercurial/exchange.py	Thu Jan 30 17:04:23 2014 -0800
+++ b/mercurial/exchange.py	Thu Jan 30 17:08:29 2014 -0800
@@ -21,7 +21,7 @@
     afterward.
     """
 
-    def __init__(self, repo, remote, force=False, revs=None):
+    def __init__(self, repo, remote, force=False, revs=None, newbranch=False):
         # repo we push from
         self.repo = repo
         self.ui = repo.ui
@@ -31,6 +31,8 @@
         self.force = force
         # revs to be pushed (None is "all")
         self.revs = revs
+        # allow push of new branch
+        self.newbranch = newbranch
 
 def push(repo, remote, force=False, revs=None, newbranch=False):
     '''Push outgoing changesets (limited by revs) from a local
@@ -41,7 +43,7 @@
         we have outgoing changesets but refused to push
       - other values as described by addchangegroup()
     '''
-    pushop = pushoperation(repo, remote, force, revs)
+    pushop = pushoperation(repo, remote, force, revs, newbranch)
     if pushop.remote.local():
         missing = (set(pushop.repo.requirements)
                    - pushop.remote.local().supported)
@@ -134,7 +136,7 @@
                                                     ctx))
                     newbm = pushop.ui.configlist('bookmarks', 'pushing')
                     discovery.checkheads(unfi, pushop.remote, outgoing,
-                                         remoteheads, newbranch,
+                                         remoteheads, pushop.newbranch,
                                          bool(inc), newbm)
 
                 # TODO: get bundlecaps from remote