Patchwork [7,of,9,(38,total)] push: move `newbranch` argument into the push object

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 2, 2014, 1:33 a.m.
Message ID <abf49396b6c4627caef5.1391304783@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3432/
State Accepted
Commit c05ad450df23b1616ff1b628f88fdb1fd45c6e75
Headers show

Comments

Pierre-Yves David - Feb. 2, 2014, 1:33 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1391130509 28800
#      Thu Jan 30 17:08:29 2014 -0800
# Node ID abf49396b6c4627caef52183d44464a33e4625cb
# Parent  c3c073e07c5fa463eac93c8d3489d466d01fbe8c
push: move `newbranch` argument into the push object

One more step toward a more modular push function.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -19,31 +19,33 @@  class pushoperation(object):
 
     A new should be created at the begining of each push and discarded
     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
         # repo we push to
         self.remote = remote
         # force option provided
         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
     repository to remote. Return an integer:
       - None means nothing to push
       - 0 means HTTP error
       - 1 means we pushed and remote head count is unchanged *or*
         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)
         if missing:
             msg = _("required features are not"
@@ -132,11 +134,11 @@  def push(repo, remote, force=False, revs
                                 raise util.Abort(_(mst)
                                                  % (ctx.troubles()[0],
                                                     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
                 bundlecaps = None
                 # create a changegroup from local