pull: wrap exchange.pull if localrepository.pull isn't available

Mercurial rev 20bb6e6b4dc5 removed localrepository.pull. We don't do it the
other way round (wrap pull if exchange.pull is available) because that's been
available with a different signature since Mercurial 3.0.
This commit is contained in:
Siddharth Agarwal 2014-10-13 23:56:13 -07:00
parent 15bce1949a
commit 04641fe869
3 changed files with 21 additions and 3 deletions

View File

@ -146,6 +146,9 @@ def extsetup(ui):
if not hgutil.safehasattr(localrepo.localrepository, 'push'):
# Mercurial >= 3.2
extensions.wrapfunction(exchange, 'push', wrappers.exchangepush)
if not hgutil.safehasattr(localrepo.localrepository, 'pull'):
# Mercurial >= 3.2
extensions.wrapfunction(exchange, 'pull', wrappers.exchangepull)
helpdir = os.path.join(os.path.dirname(__file__), 'help')

View File

@ -103,9 +103,11 @@ def generate_repo_class(ui, repo):
def push(self, remote, force=False, revs=None, newbranch=None):
return wrappers.push(self, remote, force, revs)
@remotesvn
def pull(self, remote, heads=[], force=False):
return wrappers.pull(self, remote, heads, force)
if hgutil.safehasattr(localrepo.localrepository, 'pull'):
# Mercurial < 3.2
@remotesvn
def pull(self, remote, heads=[], force=False):
return wrappers.pull(self, remote, heads, force)
@remotesvn
def findoutgoing(self, remote, base=None, heads=None, force=False):

View File

@ -518,6 +518,19 @@ def pull(repo, source, heads=[], force=False):
else:
ui.status("pulled %d revisions\n" % revisions)
def exchangepull(orig, repo, remote, heads=None, force=False, bookmarks=()):
capable = getattr(remote, 'capable', lambda x: False)
if capable('subversion'):
pullop = exchange.pulloperation(repo, remote, heads, force,
bookmarks=bookmarks)
try:
pullop.cgresult = pull(repo, remote, heads, force)
return pullop
finally:
pullop.releasetransaction()
else:
return orig(repo, remote, heads, force, bookmarks=bookmarks)
def rebase(orig, ui, repo, **opts):
"""rebase current unpushed revisions onto the Subversion head