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 (15 lines) | |||
M | hgext/narrow/narrowwirepeer.py (12 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 heads between server and client | common is set of common heads 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 | |||||
commonnodes = set() | commonnodes = set() | ||||
cl = repo.changelog | cl = repo.changelog | ||||
for r in repo.revs("::%ln", common): | for r in repo.revs("::%ln", common): | ||||
commonnodes.add(cl.node(r)) | commonnodes.add(cl.node(r)) | ||||
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') |
newincludes: the new includes of the narrow copy | newincludes: the new includes of the narrow copy | ||||
newexcludes: the new excludes of the narrow copy | newexcludes: the new excludes of the narrow copy | ||||
commonheads: list of heads which are common between the server and client | commonheads: list of heads which are common between the server and client | ||||
cgversion(maybe): the changegroup version to produce | cgversion(maybe): the changegroup version to produce | ||||
known: list of nodes which are known on the client (used in ellipses cases) | known: list of nodes which are known on the client (used in ellipses cases) | ||||
ellipses: whether to send ellipses data or not | ellipses: whether to send ellipses data or not | ||||
""" | """ | ||||
bundler = bundle2.bundle20(repo.ui) | |||||
try: | try: | ||||
oldincludes = wireprototypes.decodelist(oldincludes) | oldincludes = wireprototypes.decodelist(oldincludes) | ||||
newincludes = wireprototypes.decodelist(newincludes) | newincludes = wireprototypes.decodelist(newincludes) | ||||
oldexcludes = wireprototypes.decodelist(oldexcludes) | oldexcludes = wireprototypes.decodelist(oldexcludes) | ||||
newexcludes = wireprototypes.decodelist(newexcludes) | newexcludes = wireprototypes.decodelist(newexcludes) | ||||
# validate the patterns | # validate the patterns | ||||
narrowspec.validatepatterns(set(oldincludes)) | narrowspec.validatepatterns(set(oldincludes)) | ||||
narrowspec.validatepatterns(set(newincludes)) | narrowspec.validatepatterns(set(newincludes)) | ||||
ellipses = bool(ellipses) | ellipses = bool(ellipses) | ||||
cgversion = cgversion | cgversion = cgversion | ||||
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) | ||||
# get changegroup data | bundler = narrowbundle2.widen_bundle(repo, diffmatch, common, known, | ||||
cg = narrowbundle2.widen_bundle(repo, diffmatch, common, known, | |||||
cgversion, 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') | |||||
except error.Abort as exc: | except error.Abort as exc: | ||||
bundler = bundle2.bundle20(repo.ui) | |||||
manargs = [('message', pycompat.bytestr(exc))] | manargs = [('message', pycompat.bytestr(exc))] | ||||
advargs = [] | advargs = [] | ||||
if exc.hint is not None: | if exc.hint is not None: | ||||
advargs.append(('hint', exc.hint)) | advargs.append(('hint', exc.hint)) | ||||
bundler.addpart(bundle2.bundlepart('error:abort', manargs, advargs)) | bundler.addpart(bundle2.bundlepart('error:abort', manargs, advargs)) | ||||
chunks = bundler.getchunks() | chunks = bundler.getchunks() | ||||
return wireprototypes.streamres(gen=chunks) | return wireprototypes.streamres(gen=chunks) |