Mercurial > hg
changeset 20349:89f90457979e
push: move `force` argument into the push object
One more step toward a more modular push function.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 30 Jan 2014 16:59:25 -0800 |
parents | d64c904db55a |
children | 8c85d968ee65 |
files | mercurial/exchange.py |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/exchange.py Thu Jan 30 16:57:01 2014 -0800 +++ b/mercurial/exchange.py Thu Jan 30 16:59:25 2014 -0800 @@ -21,12 +21,14 @@ afterward. """ - def __init__(self, repo, remote): + def __init__(self, repo, remote, force=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 def push(repo, remote, force=False, revs=None, newbranch=False): '''Push outgoing changesets (limited by revs) from a local @@ -37,7 +39,7 @@ we have outgoing changesets but refused to push - other values as described by addchangegroup() ''' - pushop = pushoperation(repo, remote) + pushop = pushoperation(repo, remote, force) if pushop.remote.local(): missing = (set(pushop.repo.requirements) - pushop.remote.local().supported) @@ -84,7 +86,7 @@ msg = 'cannot lock source repository: %s\n' % err pushop.ui.debug(msg) try: - pushop.repo.checkpush(force, revs) + pushop.repo.checkpush(pushop.force, revs) lock = None unbundle = pushop.remote.capable('unbundle') if not unbundle: @@ -92,11 +94,11 @@ try: # discovery fci = discovery.findcommonincoming - commoninc = fci(unfi, pushop.remote, force=force) + commoninc = fci(unfi, pushop.remote, force=pushop.force) common, inc, remoteheads = commoninc fco = discovery.findcommonoutgoing outgoing = fco(unfi, pushop.remote, onlyheads=revs, - commoninc=commoninc, force=force) + commoninc=commoninc, force=pushop.force) if not outgoing.missing: @@ -105,7 +107,7 @@ ret = None else: # something to push - if not force: + if not pushop.force: # if repo.obsstore == False --> no obsolete # then, save the iteration if unfi.obsstore: @@ -155,7 +157,7 @@ # revs it must push. once revs transferred, if server # finds it has different heads (someone else won # commit/push race), server aborts. - if force: + if pushop.force: remoteheads = ['force'] # ssh: return remote's addchangegroup() # http: return remote's addchangegroup() or 0 for error