Mercurial > public > mercurial-scm > hg-stable
diff hgext/transplant.py @ 12734:5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
The pattern where we fetch incoming remote changes and return
them as a local bundlerepo seems common. It's nicer to have this
code unified.
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Thu, 14 Oct 2010 22:41:43 +0200 |
parents | 19dabc8a3236 |
children | f13acb96b2a7 |
line wrap: on
line diff
--- a/hgext/transplant.py Tue Oct 12 23:33:43 2010 -0500 +++ b/hgext/transplant.py Thu Oct 14 22:41:43 2010 +0200 @@ -15,8 +15,8 @@ from mercurial.i18n import _ import os, tempfile -from mercurial import bundlerepo, changegroup, cmdutil, hg, merge, match -from mercurial import patch, revlog, util, error, discovery +from mercurial import bundlerepo, cmdutil, hg, merge, match +from mercurial import patch, revlog, util, error from mercurial import revset, help class transplantentry(object): @@ -484,25 +484,6 @@ and then resume where you left off by calling :hg:`transplant --continue/-c`. ''' - def getremotechanges(repo, url): - sourcerepo = ui.expandpath(url) - source = hg.repository(ui, sourcerepo) - tmp = discovery.findcommonincoming(repo, source, force=True) - common, incoming, rheads = tmp - if not incoming: - return (source, None, None) - - bundle = None - if not source.local(): - if source.capable('changegroupsubset'): - cg = source.changegroupsubset(incoming, rheads, 'incoming') - else: - cg = source.changegroup(incoming, 'incoming') - bundle = changegroup.writebundle(cg, None, 'HG10UN') - source = bundlerepo.bundlerepository(ui, repo.root, bundle) - - return (source, incoming, bundle) - def incwalk(repo, incoming, branches, match=util.always): if not branches: branches = None @@ -559,7 +540,10 @@ bundle = None source = opts.get('source') if source: - (source, incoming, bundle) = getremotechanges(repo, source) + sourcerepo = ui.expandpath(source) + source = hg.repository(ui, sourcerepo) + source, incoming, bundle = bundlerepo.getremotechanges(ui, repo, source, + force=True) else: source = repo