Mercurial > hgsubversion
diff hgsubversion/wrappers.py @ 1246:2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Mercurial rev 4d52e6eb98ea removed localrepository.push. We don't do it the
other way round (wrap push if exchange.push is available) because that's been
available with a different signature since Mercurial 3.0.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 13 Oct 2014 23:55:27 -0700 |
parents | f367a4462191 |
children | 3a4d74823187 |
line wrap: on
line diff
--- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -2,6 +2,12 @@ from hgext import rebase as hgrebase from mercurial import cmdutil from mercurial import discovery +try: + from mercurial import exchange + exchange.push # existed in first iteration of this file +except ImportError: + # We only *use* the exchange module in hg 3.2+, so this is safe + pass from mercurial import patch from mercurial import hg from mercurial import util as hgutil @@ -362,6 +368,16 @@ def push(repo, dest, force, revs): util.swap_out_encoding(old_encoding) return 1 # so we get a sane exit status, see hg's commands.push +def exchangepush(orig, repo, remote, force=False, revs=None, newbranch=False, + bookmarks=()): + capable = getattr(remote, 'capable', lambda x: False) + if capable('subversion'): + pushop = exchange.pushoperation(repo, remote, force, revs, newbranch, + bookmarks=bookmarks) + pushop.cgresult = push(repo, remote, force, revs) + return pushop + else: + return orig(repo, remote, force, revs, newbranch, bookmarks=bookmarks) def pull(repo, source, heads=[], force=False): """pull new revisions from Subversion"""