##// END OF EJS Templates
narrowbundle2: mark most constants as module-private...
Augie Fackler -
r36104:844f253d default
parent child Browse files
Show More
@@ -35,17 +35,17 b' from . import ('
35 35 )
36 36
37 37 NARROWCAP = 'narrow'
38 NARROWACL_SECTION = 'narrowhgacl'
39 CHANGESPECPART = NARROWCAP + ':changespec'
40 SPECPART = NARROWCAP + ':spec'
41 SPECPART_INCLUDE = 'include'
42 SPECPART_EXCLUDE = 'exclude'
43 KILLNODESIGNAL = 'KILL'
44 DONESIGNAL = 'DONE'
45 ELIDEDCSHEADER = '>20s20s20sl' # cset id, p1, p2, len(text)
46 ELIDEDMFHEADER = '>20s20s20s20sl' # manifest id, p1, p2, link id, len(text)
47 CSHEADERSIZE = struct.calcsize(ELIDEDCSHEADER)
48 MFHEADERSIZE = struct.calcsize(ELIDEDMFHEADER)
38 _NARROWACL_SECTION = 'narrowhgacl'
39 _CHANGESPECPART = NARROWCAP + ':changespec'
40 _SPECPART = NARROWCAP + ':spec'
41 _SPECPART_INCLUDE = 'include'
42 _SPECPART_EXCLUDE = 'exclude'
43 _KILLNODESIGNAL = 'KILL'
44 _DONESIGNAL = 'DONE'
45 _ELIDEDCSHEADER = '>20s20s20sl' # cset id, p1, p2, len(text)
46 _ELIDEDMFHEADER = '>20s20s20s20sl' # manifest id, p1, p2, link id, len(text)
47 _CSHEADERSIZE = struct.calcsize(_ELIDEDCSHEADER)
48 _MFHEADERSIZE = struct.calcsize(_ELIDEDMFHEADER)
49 49
50 50 # When advertising capabilities, always include narrow clone support.
51 51 def getrepocaps_narrow(orig, repo, **kwargs):
@@ -250,13 +250,13 b' def getbundlechangegrouppart_narrow(bund'
250 250 part.addparam('treemanifest', '1')
251 251
252 252 if include or exclude:
253 narrowspecpart = bundler.newpart(SPECPART)
253 narrowspecpart = bundler.newpart(_SPECPART)
254 254 if include:
255 255 narrowspecpart.addparam(
256 SPECPART_INCLUDE, '\n'.join(include), mandatory=True)
256 _SPECPART_INCLUDE, '\n'.join(include), mandatory=True)
257 257 if exclude:
258 258 narrowspecpart.addparam(
259 SPECPART_EXCLUDE, '\n'.join(exclude), mandatory=True)
259 _SPECPART_EXCLUDE, '\n'.join(exclude), mandatory=True)
260 260
261 261 return
262 262
@@ -298,10 +298,10 b' def getbundlechangegrouppart_narrow(bund'
298 298 deadrevs = known
299 299 def genkills():
300 300 for r in deadrevs:
301 yield KILLNODESIGNAL
301 yield _KILLNODESIGNAL
302 302 yield repo.changelog.node(r)
303 yield DONESIGNAL
304 bundler.newpart(CHANGESPECPART, data=genkills())
303 yield _DONESIGNAL
304 bundler.newpart(_CHANGESPECPART, data=genkills())
305 305 newvisit, newfull, newellipsis = _computeellipsis(
306 306 repo, set(), common, known, newmatch)
307 307 if newvisit:
@@ -329,14 +329,14 b' def getbundlechangegrouppart_narrow(bund'
329 329 def applyacl_narrow(repo, kwargs):
330 330 username = repo.ui.shortuser(repo.ui.username())
331 331 user_includes = repo.ui.configlist(
332 NARROWACL_SECTION, username + '.includes',
333 repo.ui.configlist(NARROWACL_SECTION, 'default.includes'))
332 _NARROWACL_SECTION, username + '.includes',
333 repo.ui.configlist(_NARROWACL_SECTION, 'default.includes'))
334 334 user_excludes = repo.ui.configlist(
335 NARROWACL_SECTION, username + '.excludes',
336 repo.ui.configlist(NARROWACL_SECTION, 'default.excludes'))
335 _NARROWACL_SECTION, username + '.excludes',
336 repo.ui.configlist(_NARROWACL_SECTION, 'default.excludes'))
337 337 if not user_includes:
338 338 raise error.Abort(_("{} configuration for user {} is empty")
339 .format(NARROWACL_SECTION, username))
339 .format(_NARROWACL_SECTION, username))
340 340
341 341 user_includes = [
342 342 'path:.' if p == '*' else 'path:' + p for p in user_includes]
@@ -363,17 +363,17 b' def applyacl_narrow(repo, kwargs):'
363 363 new_args['excludepats'] = req_excludes
364 364 return new_args
365 365
366 @bundle2.parthandler(SPECPART, (SPECPART_INCLUDE, SPECPART_EXCLUDE))
366 @bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE))
367 367 def _handlechangespec_2(op, inpart):
368 includepats = set(inpart.params.get(SPECPART_INCLUDE, '').splitlines())
369 excludepats = set(inpart.params.get(SPECPART_EXCLUDE, '').splitlines())
368 includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines())
369 excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines())
370 370 narrowspec.save(op.repo, includepats, excludepats)
371 371 if not narrowrepo.requirement in op.repo.requirements:
372 372 op.repo.requirements.add(narrowrepo.requirement)
373 373 op.repo._writerequirements()
374 374 op.repo.invalidate(clearfilecache=True)
375 375
376 @bundle2.parthandler(CHANGESPECPART)
376 @bundle2.parthandler(_CHANGESPECPART)
377 377 def _handlechangespec(op, inpart):
378 378 repo = op.repo
379 379 cl = repo.changelog
@@ -388,8 +388,8 b' def _handlechangespec(op, inpart):'
388 388 # repo. All the changes that this block encounters are ellipsis
389 389 # nodes or flags to kill an existing ellipsis.
390 390 chunksignal = changegroup.readexactly(inpart, 4)
391 while chunksignal != DONESIGNAL:
392 if chunksignal == KILLNODESIGNAL:
391 while chunksignal != _DONESIGNAL:
392 if chunksignal == _KILLNODESIGNAL:
393 393 # a node used to be an ellipsis but isn't anymore
394 394 ck = changegroup.readexactly(inpart, 20)
395 395 if cl.hasnode(ck):
@@ -477,7 +477,7 b' def setup():'
477 477 origcgfn = exchange.getbundle2partsmapping['changegroup']
478 478 def wrappedcgfn(*args, **kwargs):
479 479 repo = args[1]
480 if repo.ui.has_section(NARROWACL_SECTION):
480 if repo.ui.has_section(_NARROWACL_SECTION):
481 481 getbundlechangegrouppart_narrow(
482 482 *args, **applyacl_narrow(repo, kwargs))
483 483 elif kwargs.get('narrow', False):
General Comments 0
You need to be logged in to leave comments. Login now