Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hg.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 | 33e1fd2aeb3c |
children | 8888e56ac417 |
line wrap: on
line diff
--- a/mercurial/hg.py Tue Oct 12 23:33:43 2010 -0500 +++ b/mercurial/hg.py Thu Oct 14 22:41:43 2010 +0200 @@ -11,7 +11,7 @@ from node import hex, nullid, nullrev, short import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo import lock, util, extensions, error, encoding, node -import cmdutil, discovery, url, changegroup +import cmdutil, discovery, url import merge as mergemod import verify as verifymod import errno, os, shutil @@ -423,38 +423,12 @@ if revs: revs = [other.lookup(rev) for rev in revs] - bundlename = opts["bundle"] - force = opts["force"] - tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force) - common, incoming, rheads = tmp - if not incoming: - try: - os.unlink(bundlename) - except: - pass + other, incoming, bundle = bundlerepo.getremotechanges(ui, repo, other, revs, + opts["bundle"], opts["force"]) + if incoming is None: ui.status(_("no changes found\n")) return subreporecurse() - bundle = None - if bundlename or not other.local(): - # create a bundle (uncompressed if other repo is not local) - - if revs is None and other.capable('changegroupsubset'): - revs = rheads - - if revs is None: - cg = other.changegroup(incoming, "incoming") - else: - cg = other.changegroupsubset(incoming, revs, 'incoming') - bundletype = other.local() and "HG10BZ" or "HG10UN" - fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) - # keep written bundle? - if bundlename: - bundle = None - if not other.local(): - # use the created uncompressed bundlerepo - other = bundlerepo.bundlerepository(ui, repo.root, fname) - try: chlist = other.changelog.nodesbetween(incoming, revs)[0] displayer = cmdutil.show_changeset(ui, other, opts, buffered)