Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHGd959277ff1b5: bundlerepo: rename "other" to "peer"
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
durin42 |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/bundlerepo.py (40 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg |
return None | return None | ||||
def close(self): | def close(self): | ||||
raise NotImplementedError | raise NotImplementedError | ||||
def release(self): | def release(self): | ||||
raise NotImplementedError | raise NotImplementedError | ||||
def getremotechanges(ui, repo, other, onlyheads=None, bundlename=None, | def getremotechanges(ui, repo, peer, onlyheads=None, bundlename=None, | ||||
force=False): | force=False): | ||||
'''obtains a bundle of changes incoming from other | '''obtains a bundle of changes incoming from peer | ||||
"onlyheads" restricts the returned changes to those reachable from the | "onlyheads" restricts the returned changes to those reachable from the | ||||
specified heads. | specified heads. | ||||
"bundlename", if given, stores the bundle to this file path permanently; | "bundlename", if given, stores the bundle to this file path permanently; | ||||
otherwise it's stored to a temp file and gets deleted again when you call | otherwise it's stored to a temp file and gets deleted again when you call | ||||
the returned "cleanupfn". | the returned "cleanupfn". | ||||
"force" indicates whether to proceed on unrelated repos. | "force" indicates whether to proceed on unrelated repos. | ||||
Returns a tuple (local, csets, cleanupfn): | Returns a tuple (local, csets, cleanupfn): | ||||
"local" is a local repo from which to obtain the actual incoming | "local" is a local repo from which to obtain the actual incoming | ||||
changesets; it is a bundlerepo for the obtained bundle when the | changesets; it is a bundlerepo for the obtained bundle when the | ||||
original "other" is remote. | original "peer" is remote. | ||||
"csets" lists the incoming changeset node ids. | "csets" lists the incoming changeset node ids. | ||||
"cleanupfn" must be called without arguments when you're done processing | "cleanupfn" must be called without arguments when you're done processing | ||||
the changes; it closes both the original "other" and the one returned | the changes; it closes both the original "peer" and the one returned | ||||
here. | here. | ||||
''' | ''' | ||||
tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, | tmp = discovery.findcommonincoming(repo, peer, heads=onlyheads, | ||||
force=force) | force=force) | ||||
common, incoming, rheads = tmp | common, incoming, rheads = tmp | ||||
if not incoming: | if not incoming: | ||||
try: | try: | ||||
if bundlename: | if bundlename: | ||||
os.unlink(bundlename) | os.unlink(bundlename) | ||||
except OSError: | except OSError: | ||||
pass | pass | ||||
return repo, [], other.close | return repo, [], peer.close | ||||
commonset = set(common) | commonset = set(common) | ||||
rheads = [x for x in rheads if x not in commonset] | rheads = [x for x in rheads if x not in commonset] | ||||
bundle = None | bundle = None | ||||
bundlerepo = None | bundlerepo = None | ||||
localrepo = other.local() | localrepo = peer.local() | ||||
if bundlename or not localrepo: | if bundlename or not localrepo: | ||||
# create a bundle (uncompressed if other repo is not local) | # create a bundle (uncompressed if peer repo is not local) | ||||
# developer config: devel.legacy.exchange | # developer config: devel.legacy.exchange | ||||
legexc = ui.configlist('devel', 'legacy.exchange') | legexc = ui.configlist('devel', 'legacy.exchange') | ||||
forcebundle1 = 'bundle2' not in legexc and 'bundle1' in legexc | forcebundle1 = 'bundle2' not in legexc and 'bundle1' in legexc | ||||
canbundle2 = (not forcebundle1 | canbundle2 = (not forcebundle1 | ||||
and other.capable('getbundle') | and peer.capable('getbundle') | ||||
and other.capable('bundle2')) | and peer.capable('bundle2')) | ||||
if canbundle2: | if canbundle2: | ||||
kwargs = {} | kwargs = {} | ||||
kwargs[r'common'] = common | kwargs[r'common'] = common | ||||
kwargs[r'heads'] = rheads | kwargs[r'heads'] = rheads | ||||
kwargs[r'bundlecaps'] = exchange.caps20to10(repo, role='client') | kwargs[r'bundlecaps'] = exchange.caps20to10(repo, role='client') | ||||
kwargs[r'cg'] = True | kwargs[r'cg'] = True | ||||
b2 = other.getbundle('incoming', **kwargs) | b2 = peer.getbundle('incoming', **kwargs) | ||||
fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(), | fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(), | ||||
bundlename) | bundlename) | ||||
else: | else: | ||||
if other.capable('getbundle'): | if peer.capable('getbundle'): | ||||
cg = other.getbundle('incoming', common=common, heads=rheads) | cg = peer.getbundle('incoming', common=common, heads=rheads) | ||||
elif onlyheads is None and not other.capable('changegroupsubset'): | elif onlyheads is None and not peer.capable('changegroupsubset'): | ||||
# compat with older servers when pulling all remote heads | # compat with older servers when pulling all remote heads | ||||
with other.commandexecutor() as e: | with peer.commandexecutor() as e: | ||||
fcg = e.callcommand('changegroup', { | fcg = e.callcommand('changegroup', { | ||||
'nodes': incoming, | 'nodes': incoming, | ||||
'source': 'incoming', | 'source': 'incoming', | ||||
}) | }) | ||||
cg = fcg.result() | cg = fcg.result() | ||||
rheads = None | rheads = None | ||||
else: | else: | ||||
with other.commandexecutor() as e: | with peer.commandexecutor() as e: | ||||
fcg = e.callcommand('changegroupsubset', { | fcg = e.callcommand('changegroupsubset', { | ||||
'bases': incoming, | 'bases': incoming, | ||||
'heads': rheads, | 'heads': rheads, | ||||
'source': 'incoming', | 'source': 'incoming', | ||||
}) | }) | ||||
cg = fcg.result() | cg = fcg.result() | ||||
if localrepo: | if localrepo: | ||||
bundletype = "HG10BZ" | bundletype = "HG10BZ" | ||||
else: | else: | ||||
bundletype = "HG10UN" | bundletype = "HG10UN" | ||||
fname = bundle = bundle2.writebundle(ui, cg, bundlename, | fname = bundle = bundle2.writebundle(ui, cg, bundlename, | ||||
bundletype) | bundletype) | ||||
# keep written bundle? | # keep written bundle? | ||||
if bundlename: | if bundlename: | ||||
bundle = None | bundle = None | ||||
if not localrepo: | if not localrepo: | ||||
# use the created uncompressed bundlerepo | # use the created uncompressed bundlerepo | ||||
localrepo = bundlerepo = bundlerepository(repo.baseui, repo.root, | localrepo = bundlerepo = bundlerepository(repo.baseui, repo.root, | ||||
fname) | fname) | ||||
# this repo contains local and other now, so filter out local again | # this repo contains local and peer now, so filter out local again | ||||
common = repo.heads() | common = repo.heads() | ||||
if localrepo: | if localrepo: | ||||
# Part of common may be remotely filtered | # Part of common may be remotely filtered | ||||
# So use an unfiltered version | # So use an unfiltered version | ||||
# The discovery process probably need cleanup to avoid that | # The discovery process probably need cleanup to avoid that | ||||
localrepo = localrepo.unfiltered() | localrepo = localrepo.unfiltered() | ||||
csets = localrepo.changelog.findmissing(common, rheads) | csets = localrepo.changelog.findmissing(common, rheads) | ||||
if bundlerepo: | if bundlerepo: | ||||
reponodes = [ctx.node() for ctx in bundlerepo[bundlerepo.firstnewrev:]] | reponodes = [ctx.node() for ctx in bundlerepo[bundlerepo.firstnewrev:]] | ||||
remotephases = other.listkeys('phases') | remotephases = peer.listkeys('phases') | ||||
pullop = exchange.pulloperation(bundlerepo, other, heads=reponodes) | pullop = exchange.pulloperation(bundlerepo, peer, heads=reponodes) | ||||
pullop.trmanager = bundletransactionmanager() | pullop.trmanager = bundletransactionmanager() | ||||
exchange._pullapplyphases(pullop, remotephases) | exchange._pullapplyphases(pullop, remotephases) | ||||
def cleanup(): | def cleanup(): | ||||
if bundlerepo: | if bundlerepo: | ||||
bundlerepo.close() | bundlerepo.close() | ||||
if bundle: | if bundle: | ||||
os.unlink(bundle) | os.unlink(bundle) | ||||
other.close() | peer.close() | ||||
return (localrepo, csets, cleanup) | return (localrepo, csets, cleanup) |