From patchwork Tue Feb 11 00:01:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [09, of, 11, (19, more, to, go)] push: move push return value in the push object From: Pierre-Yves David X-Patchwork-Id: 3555 Message-Id: <7dfa48719256385ab66a.1392076897@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Mon, 10 Feb 2014 16:01:37 -0800 # HG changeset patch # User Pierre-Yves David # Date 1391139808 28800 # Thu Jan 30 19:43:28 2014 -0800 # Node ID 7dfa48719256385ab66aa5a666891bde653c8eb5 # Parent f07aad217fedbb12406be847e6d4e6bf18c8c878 push: move push return value in the push object The return code convey information about the success of changeset push. This is used by phases to compute the new common set between local and remote. So we need to move it into the object to extract the phase sync from the god function. Note that this information will be used by obsolescence markers too. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -33,10 +33,17 @@ class pushoperation(object): self.revs = revs # allow push of new branch self.newbranch = newbranch # did a local lock get acquired? self.locallocked = None + # Integer version of the push result + # - 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() + self.ret = None 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 @@ -97,11 +104,10 @@ def push(repo, remote, force=False, revs if not outgoing.missing: # nothing to push scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded) - ret = None else: # something to push if not pushop.force: # if repo.obsstore == False --> no obsolete # then, save the iteration @@ -154,18 +160,19 @@ def push(repo, remote, force=False, revs # commit/push race), server aborts. if pushop.force: remoteheads = ['force'] # ssh: return remote's addchangegroup() # http: return remote's addchangegroup() or 0 for error - ret = pushop.remote.unbundle(cg, remoteheads, 'push') + pushop.ret = pushop.remote.unbundle(cg, remoteheads, + 'push') else: # we return an integer indicating remote head count # change - ret = pushop.remote.addchangegroup(cg, 'push', - pushop.repo.url()) + pushop.ret = pushop.remote.addchangegroup(cg, 'push', + pushop.repo.url()) - if ret: + if pushop.ret: # push succeed, synchronize target of the push cheads = outgoing.missingheads elif pushop.revs is None: # All out push fails. synchronize all common cheads = outgoing.commonheads @@ -195,11 +202,11 @@ def push(repo, remote, force=False, revs cheads.extend(c.node() for c in revset) # even when we don't push, exchanging phase data is useful remotephases = pushop.remote.listkeys('phases') if (pushop.ui.configbool('ui', '_usedassubrepo', False) and remotephases # server supports phases - and ret is None # nothing was pushed + and pushop.ret is None # nothing was pushed and remotephases.get('publishing', False)): # When: # - this is a subrepo push # - and remote support phase # - and no changeset was pushed @@ -244,11 +251,11 @@ def push(repo, remote, force=False, revs finally: if locallock is not None: locallock.release() _pushbookmark(pushop) - return ret + return pushop.ret def _localphasemove(pushop, nodes, phase=phases.public): """move to in the local source repo""" if pushop.locallocked: phases.advanceboundary(pushop.repo, phase, nodes)