comparison mercurial/exchange.py @ 42209:280f7a095df8 stable

narrow: send specs as bundle2 data instead of param (issue5952) (issue6019) Before this patch, when ACL is involved, narrowspecs are send as bundle2 parameter for narrow:spec bundle2 part. The limitation of bundle2 parts are they cannot send data larger than 255 bytes. Includes and excludes in narrow are not limited by size and they can grow over 255 bytes. This patch introduces a new mandatory bundle2 part and send narrowspecs as data of that. The new bundle2 part is introduced to keep things cleaner and easy to distinguish related to backward compatibility. The part is mandatory because without server's narrowspec, the local ACL narrow repo won't work. This patch makes clients compatible with servers which have older versions. However I left a comment that we should drop the other bundle2 part soon as that's broken and people should not rely on that. I named the new bundle2 part 'Narrow:responsespec' because: 1) Capital 'N' to make it mandatory 2) 'Narrow:spec' cannot be used because bundle2 enforces that there should not be two different parts which resolve to same name when lowercased. 3) reponsespec clears that they are specs which are send as reponse by the server While I was here, I renamed `narrowhgacl` section to `narrowacl` as suggested by idlsoft@ and martinvonz@. Differential Revision: https://phab.mercurial-scm.org/D6310
author Pulkit Goyal <pulkit@yandex-team.ru>
date Wed, 17 Apr 2019 15:06:41 +0300
parents 566daffc607d
children 5d4ec64a6fcb
comparison
equal deleted inserted replaced
42204:723ed4402896 42209:280f7a095df8
47 ) 47 )
48 48
49 urlerr = util.urlerr 49 urlerr = util.urlerr
50 urlreq = util.urlreq 50 urlreq = util.urlreq
51 51
52 _NARROWACL_SECTION = 'narrowhgacl' 52 _NARROWACL_SECTION = 'narrowacl'
53 53
54 # Maps bundle version human names to changegroup versions. 54 # Maps bundle version human names to changegroup versions.
55 _bundlespeccgversions = {'v1': '01', 55 _bundlespeccgversions = {'v1': '01',
56 'v2': '02', 56 'v2': '02',
57 'packed1': 's1', 57 'packed1': 's1',
2211 if 'treemanifest' in repo.requirements: 2211 if 'treemanifest' in repo.requirements:
2212 part.addparam('treemanifest', '1') 2212 part.addparam('treemanifest', '1')
2213 2213
2214 if (kwargs.get(r'narrow', False) and kwargs.get(r'narrow_acl', False) 2214 if (kwargs.get(r'narrow', False) and kwargs.get(r'narrow_acl', False)
2215 and (include or exclude)): 2215 and (include or exclude)):
2216 narrowspecpart = bundler.newpart('narrow:spec') 2216 # this is mandatory because otherwise ACL clients won't work
2217 if include: 2217 narrowspecpart = bundler.newpart('Narrow:responsespec')
2218 narrowspecpart.addparam( 2218 narrowspecpart.data = '%s\0%s' % ('\n'.join(include),
2219 'include', '\n'.join(include), mandatory=True) 2219 '\n'.join(exclude))
2220 if exclude:
2221 narrowspecpart.addparam(
2222 'exclude', '\n'.join(exclude), mandatory=True)
2223 2220
2224 @getbundle2partsgenerator('bookmarks') 2221 @getbundle2partsgenerator('bookmarks')
2225 def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None, 2222 def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None,
2226 b2caps=None, **kwargs): 2223 b2caps=None, **kwargs):
2227 """add a bookmark part to the requested bundle""" 2224 """add a bookmark part to the requested bundle"""