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