##// END OF EJS Templates
narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)...
Pulkit Goyal -
r42393:280f7a09 stable
parent child Browse files
Show More
@@ -31,8 +31,9 b' from mercurial.utils import ('
31 stringutil,
31 stringutil,
32 )
32 )
33
33
34 _NARROWACL_SECTION = 'narrowhgacl'
34 _NARROWACL_SECTION = 'narrowacl'
35 _CHANGESPECPART = 'narrow:changespec'
35 _CHANGESPECPART = 'narrow:changespec'
36 _RESSPECS = 'narrow:responsespec'
36 _SPECPART = 'narrow:spec'
37 _SPECPART = 'narrow:spec'
37 _SPECPART_INCLUDE = 'include'
38 _SPECPART_INCLUDE = 'include'
38 _SPECPART_EXCLUDE = 'exclude'
39 _SPECPART_EXCLUDE = 'exclude'
@@ -142,6 +143,10 b' def getbundlechangegrouppart_narrow(bund'
142
143
143 @bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE))
144 @bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE))
144 def _handlechangespec_2(op, inpart):
145 def _handlechangespec_2(op, inpart):
146 # XXX: This bundle2 handling is buggy and should be removed after hg5.2 is
147 # released. New servers will send a mandatory bundle2 part named
148 # 'Narrowspec' and will send specs as data instead of params.
149 # Refer to issue5952 and 6019
145 includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines())
150 includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines())
146 excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines())
151 excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines())
147 narrowspec.validatepatterns(includepats)
152 narrowspec.validatepatterns(includepats)
@@ -153,6 +158,21 b' def _handlechangespec_2(op, inpart):'
153 op.repo.setnarrowpats(includepats, excludepats)
158 op.repo.setnarrowpats(includepats, excludepats)
154 narrowspec.copytoworkingcopy(op.repo)
159 narrowspec.copytoworkingcopy(op.repo)
155
160
161 @bundle2.parthandler(_RESSPECS)
162 def _handlenarrowspecs(op, inpart):
163 data = inpart.read()
164 inc, exc = data.split('\0')
165 includepats = set(inc.splitlines())
166 excludepats = set(exc.splitlines())
167 narrowspec.validatepatterns(includepats)
168 narrowspec.validatepatterns(excludepats)
169
170 if repository.NARROW_REQUIREMENT not in op.repo.requirements:
171 op.repo.requirements.add(repository.NARROW_REQUIREMENT)
172 op.repo._writerequirements()
173 op.repo.setnarrowpats(includepats, excludepats)
174 narrowspec.copytoworkingcopy(op.repo)
175
156 @bundle2.parthandler(_CHANGESPECPART)
176 @bundle2.parthandler(_CHANGESPECPART)
157 def _handlechangespec(op, inpart):
177 def _handlechangespec(op, inpart):
158 repo = op.repo
178 repo = op.repo
@@ -49,7 +49,7 b' from .utils import ('
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',
@@ -2213,13 +2213,10 b' def _getbundlechangegrouppart(bundler, r'
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,
@@ -10,7 +10,7 b' Make a narrow clone then archive it'
10 > hg commit -m "Add $x"
10 > hg commit -m "Add $x"
11 > done
11 > done
12 $ cat >> .hg/hgrc << EOF
12 $ cat >> .hg/hgrc << EOF
13 > [narrowhgacl]
13 > [narrowacl]
14 > default.includes=f1 f2
14 > default.includes=f1 f2
15 > EOF
15 > EOF
16 $ hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid
16 $ hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid
General Comments 0
You need to be logged in to leave comments. Login now