##// END OF EJS Templates
fileset: build status according to 'withstatus' hint...
Yuya Nishihara -
r38916:80fd7371 default
parent child Browse files
Show More
@@ -44,7 +44,8 b' def getmatch(mctx, x):'
44 44 return methods[x[0]](mctx, *x[1:])
45 45
46 46 def getmatchwithstatus(mctx, x, hint):
47 return getmatch(mctx, x)
47 keys = set(getstring(hint, 'status hint must be a string').split())
48 return getmatch(mctx.withstatus(keys), x)
48 49
49 50 def stringmatch(mctx, x):
50 51 return mctx.matcher([x])
@@ -98,9 +99,6 b' def func(mctx, a, b):'
98 99 # x - argument in tree form
99 100 symbols = filesetlang.symbols
100 101
101 # filesets using matchctx.status()
102 _statuscallers = set()
103
104 102 predicate = registrar.filesetpredicate()
105 103
106 104 @predicate('modified()', callstatus=True, weight=_WEIGHT_STATUS)
@@ -390,7 +388,6 b' def revs(mctx, x):'
390 388 for r in revs:
391 389 ctx = repo[r]
392 390 mc = mctx.switch(ctx.p1(), ctx)
393 mc.buildstatus(x)
394 391 matchers.append(getmatch(mc, x))
395 392 if not matchers:
396 393 return mctx.never()
@@ -419,7 +416,6 b' def status(mctx, x):'
419 416 raise error.ParseError(reverr)
420 417 basectx, ctx = scmutil.revpair(repo, [baserevspec, revspec])
421 418 mc = mctx.switch(basectx, ctx)
422 mc.buildstatus(x)
423 419 return getmatch(mc, x)
424 420
425 421 @predicate('subrepo([pattern])')
@@ -466,15 +462,17 b' class matchctx(object):'
466 462 self._badfn = badfn
467 463 self._status = None
468 464
469 def buildstatus(self, tree):
470 if not _intree(_statuscallers, tree):
471 return
472 unknown = _intree(['unknown'], tree)
473 ignored = _intree(['ignored'], tree)
465 def withstatus(self, keys):
466 """Create matchctx which has precomputed status specified by the keys"""
467 mctx = matchctx(self._basectx, self.ctx, self._badfn)
468 mctx._buildstatus(keys)
469 return mctx
470
471 def _buildstatus(self, keys):
474 472 self._status = self._basectx.status(self.ctx,
475 listignored=ignored,
473 listignored='ignored' in keys,
476 474 listclean=True,
477 listunknown=unknown)
475 listunknown='unknown' in keys)
478 476
479 477 def status(self):
480 478 return self._status
@@ -533,32 +531,12 b' class matchctx(object):'
533 531 def switch(self, basectx, ctx):
534 532 return matchctx(basectx, ctx, self._badfn)
535 533
536 # filesets using matchctx.switch()
537 _switchcallers = [
538 'revs',
539 'status',
540 ]
541
542 def _intree(funcs, tree):
543 if isinstance(tree, tuple):
544 if tree[0] == 'func' and tree[1][0] == 'symbol':
545 if tree[1][1] in funcs:
546 return True
547 if tree[1][1] in _switchcallers:
548 # arguments won't be evaluated in the current context
549 return False
550 for s in tree[1:]:
551 if _intree(funcs, s):
552 return True
553 return False
554
555 534 def match(ctx, expr, badfn=None):
556 535 """Create a matcher for a single fileset expression"""
557 536 tree = filesetlang.parse(expr)
558 537 tree = filesetlang.analyze(tree)
559 538 tree = filesetlang.optimize(tree)
560 539 mctx = matchctx(ctx.p1(), ctx, badfn=badfn)
561 mctx.buildstatus(tree)
562 540 return getmatch(mctx, tree)
563 541
564 542
@@ -567,10 +545,8 b' def loadpredicate(ui, extname, registrar'
567 545 """
568 546 for name, func in registrarobj._table.iteritems():
569 547 symbols[name] = func
570 if func._callstatus:
571 _statuscallers.add(name)
572 548
573 # load built-in predicates explicitly to setup _statuscallers
549 # load built-in predicates explicitly
574 550 loadpredicate(None, None, predicate)
575 551
576 552 # tell hggettext to extract docstrings from these functions:
General Comments 0
You need to be logged in to leave comments. Login now