##// END OF EJS Templates
narrowbundle2: make constants ALLCAPS to be a bit more readable...
Augie Fackler -
r36103:bc01f48c default
parent child Browse files
Show More
@@ -34,23 +34,23 b' from . import ('
34 narrowspec,
34 narrowspec,
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):
52 caps = orig(repo, **kwargs)
52 caps = orig(repo, **kwargs)
53 caps[narrowcap] = ['v0']
53 caps[NARROWCAP] = ['v0']
54 return caps
54 return caps
55
55
56 def _computeellipsis(repo, common, heads, known, match, depth=None):
56 def _computeellipsis(repo, common, heads, known, match, depth=None):
@@ -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):
@@ -147,7 +147,7 b' def pullbundle2extraprepare(orig, pullop'
147 if narrowrepo.requirement not in repo.requirements:
147 if narrowrepo.requirement not in repo.requirements:
148 return orig(pullop, kwargs)
148 return orig(pullop, kwargs)
149
149
150 if narrowbundle2.narrowcap not in pullop.remotebundle2caps:
150 if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
151 raise error.Abort(_("server doesn't support narrow clones"))
151 raise error.Abort(_("server doesn't support narrow clones"))
152 orig(pullop, kwargs)
152 orig(pullop, kwargs)
153 kwargs['narrow'] = True
153 kwargs['narrow'] = True
General Comments 0
You need to be logged in to leave comments. Login now