Details
Details
- Reviewers
durin42 martinvonz - Group Reviewers
hg-reviewers - Commits
- rHGe8132a8897da: narrow: start returning bundle2 from widen_bundle()
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
durin42 | |
martinvonz |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/narrow/narrowbundle2.py (16 lines) | |||
M | hgext/narrow/narrowwirepeer.py (9 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Pulkit Goyal | Oct 2 2018, 10:09 AM |
# When advertising capabilities, always include narrow clone support. | # When advertising capabilities, always include narrow clone support. | ||||
def getrepocaps_narrow(orig, repo, **kwargs): | def getrepocaps_narrow(orig, repo, **kwargs): | ||||
caps = orig(repo, **kwargs) | caps = orig(repo, **kwargs) | ||||
caps[NARROWCAP] = ['v0'] | caps[NARROWCAP] = ['v0'] | ||||
return caps | return caps | ||||
def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses): | def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses): | ||||
"""generates changegroup for widening a narrow clone | """generates bundle2 for widening a narrow clone | ||||
repo is the localrepository instance | repo is the localrepository instance | ||||
diffmatcher is a differencemacther of '(newincludes, newexcludes) - | diffmatcher is a differencemacther of '(newincludes, newexcludes) - | ||||
(oldincludes, oldexcludes)' | (oldincludes, oldexcludes)' | ||||
common is set of common revs between server and client | common is set of common revs between server and client | ||||
known is a set of revs known on the client side (used in ellipses) | known is a set of revs known on the client side (used in ellipses) | ||||
cgversion is the changegroup version to send | cgversion is the changegroup version to send | ||||
ellipses is boolean value telling whether to send ellipses data or not | ellipses is boolean value telling whether to send ellipses data or not | ||||
returns changegroup data of the changegroup built or return None if there | returns bundle2 of the data required for extending | ||||
are no common revs | |||||
""" | """ | ||||
# XXX: This patch will start sending bundle2 after couple of patches when | bundler = bundle2.bundle20(repo.ui) | ||||
# called from the wireprotocol command | |||||
common = repo.revs("::%ln", common) | common = repo.revs("::%ln", common) | ||||
commonnodes = set() | commonnodes = set() | ||||
cl = repo.changelog | cl = repo.changelog | ||||
for c in common: | for c in common: | ||||
commonnodes.add(cl.node(c)) | commonnodes.add(cl.node(c)) | ||||
if commonnodes: | if commonnodes: | ||||
# XXX: we should only send the filelogs (and treemanifest). user | # XXX: we should only send the filelogs (and treemanifest). user | ||||
# already has the changelog and manifest | # already has the changelog and manifest | ||||
packer = changegroup.getbundler(cgversion, repo, | packer = changegroup.getbundler(cgversion, repo, | ||||
filematcher=diffmatcher, | filematcher=diffmatcher, | ||||
fullnodes=commonnodes) | fullnodes=commonnodes) | ||||
cgdata = packer.generate(set([nullid]), list(commonnodes), False, | cgdata = packer.generate(set([nullid]), list(commonnodes), False, | ||||
'narrow_widen', changelog=False) | 'narrow_widen', changelog=False) | ||||
return cgdata | part = bundler.newpart('changegroup', data=cgdata) | ||||
part.addparam('version', cgversion) | |||||
if 'treemanifest' in repo.requirements: | |||||
part.addparam('treemanifest', '1') | |||||
return None | return bundler | ||||
# Serve a changegroup for a client with a narrow clone. | # Serve a changegroup for a client with a narrow clone. | ||||
def getbundlechangegrouppart_narrow(bundler, repo, source, | def getbundlechangegrouppart_narrow(bundler, repo, source, | ||||
bundlecaps=None, b2caps=None, heads=None, | bundlecaps=None, b2caps=None, heads=None, | ||||
common=None, **kwargs): | common=None, **kwargs): | ||||
assert repo.ui.configbool('experimental', 'narrowservebrokenellipses') | assert repo.ui.configbool('experimental', 'narrowservebrokenellipses') | ||||
cgversions = b2caps.get('changegroup') | cgversions = b2caps.get('changegroup') |
newmatch = narrowspec.match(repo.root, include=newincludes, | newmatch = narrowspec.match(repo.root, include=newincludes, | ||||
exclude=newexcludes) | exclude=newexcludes) | ||||
oldmatch = narrowspec.match(repo.root, include=oldincludes, | oldmatch = narrowspec.match(repo.root, include=oldincludes, | ||||
exclude=oldexcludes) | exclude=oldexcludes) | ||||
diffmatch = matchmod.differencematcher(newmatch, oldmatch) | diffmatch = matchmod.differencematcher(newmatch, oldmatch) | ||||
bundler = bundle2.bundle20(repo.ui) | bundler = bundle2.bundle20(repo.ui) | ||||
# get changegroup data | # get changegroup data | ||||
cg = narrowbundle2.widen_bundle(repo, diffmatch, common, known, cgversion, | bundler = narrowbundle2.widen_bundle(repo, diffmatch, common, known, | ||||
ellipses) | cgversion, ellipses) | ||||
if cg is not None: | |||||
part = bundler.newpart('changegroup', data=cg) | |||||
part.addparam('version', cgversion) | |||||
if 'treemanifest' in repo.requirements: | |||||
part.addparam('treemanifest', '1') | |||||
chunks = bundler.getchunks() | chunks = bundler.getchunks() | ||||
return wireprototypes.streamres(gen=chunks) | return wireprototypes.streamres(gen=chunks) | ||||
def peernarrowwiden(remote, **kwargs): | def peernarrowwiden(remote, **kwargs): | ||||
for ch in ('oldincludes', 'newincludes', 'oldexcludes', 'newexcludes', | for ch in ('oldincludes', 'newincludes', 'oldexcludes', 'newexcludes', | ||||
'common', 'known'): | 'common', 'known'): | ||||
kwargs[ch] = wireprototypes.encodelist(kwargs[ch]) | kwargs[ch] = wireprototypes.encodelist(kwargs[ch]) | ||||
kwargs['ellipses'] = '%i' % bool(kwargs['ellipses']) | kwargs['ellipses'] = '%i' % bool(kwargs['ellipses']) | ||||
f = remote._callcompressable('narrow_widen', **kwargs) | f = remote._callcompressable('narrow_widen', **kwargs) | ||||
return bundle2.getunbundler(remote.ui, f) | return bundle2.getunbundler(remote.ui, f) |