Mercurial > hg-git
diff hggit/__init__.py @ 780:db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Mercurial rev 73b5b8312ce6 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.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 13 Oct 2014 18:53:42 -0700 |
parents | 4a9057b16f40 |
children | 8bfb1d72b49c |
line wrap: on
line diff
--- a/hggit/__init__.py Mon Oct 13 16:26:31 2014 -0700 +++ b/hggit/__init__.py Mon Oct 13 18:53:42 2014 -0700 @@ -27,6 +27,7 @@ from mercurial import demandimport from mercurial import dirstate from mercurial import discovery +from mercurial import exchange from mercurial import extensions from mercurial import help from mercurial import hg @@ -44,7 +45,7 @@ 'collections', ]) -import gitrepo, hgrepo +import gitrepo, hgrepo, util from git_handler import GitHandler import verify @@ -210,6 +211,25 @@ return newpeer extensions.wrapfunction(hg, 'peer', peer) +@util.transform_notgit +def exchangepull(orig, repo, remote, heads=None, force=False, bookmarks=()): + if isinstance(remote, gitrepo.gitrepo): + pullop = exchange.pulloperation(repo, remote, heads, force, + bookmarks=bookmarks) + lock = repo.lock() + try: + pullop.cgresult = repo.githandler.fetch(remote.path, heads) + pullop.closetransaction() + return pullop + finally: + pullop.releasetransaction() + lock.release() + else: + return orig(repo, remote, heads, force, bookmarks=bookmarks) +if not hgutil.safehasattr(localrepo.localrepository, 'pull'): + # Mercurial >= 3.2 + extensions.wrapfunction(exchange, 'pull', exchangepull) + def revset_fromgit(repo, subset, x): '''``fromgit()`` Select changesets that originate from Git.