comparison mercurial/fileset.py @ 31191:3c3ab84e6e78

fileset: extract function that builds status tuple only if necessary This function will be used to recalculate status when mctx.ctx is switched.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 24 Jan 2015 19:13:39 +0900
parents 2f881e7d1ade
children 951d95b13487
comparison
equal deleted inserted replaced
31190:2f881e7d1ade 31191:3c3ab84e6e78
524 else: 524 else:
525 return list(ctx.walk(ctx.match([]))) 525 return list(ctx.walk(ctx.match([])))
526 526
527 def getfileset(ctx, expr): 527 def getfileset(ctx, expr):
528 tree = parse(expr) 528 tree = parse(expr)
529 529 return getset(fullmatchctx(ctx, _buildstatus(ctx, tree)), tree)
530
531 def _buildstatus(ctx, tree):
530 # do we need status info? 532 # do we need status info?
531 if (_intree(_statuscallers, tree) or 533 if (_intree(_statuscallers, tree) or
532 # Using matchctx.existing() on a workingctx requires us to check 534 # Using matchctx.existing() on a workingctx requires us to check
533 # for deleted files. 535 # for deleted files.
534 (ctx.rev() is None and _intree(_existingcallers, tree))): 536 (ctx.rev() is None and _intree(_existingcallers, tree))):
535 unknown = _intree(['unknown'], tree) 537 unknown = _intree(['unknown'], tree)
536 ignored = _intree(['ignored'], tree) 538 ignored = _intree(['ignored'], tree)
537 539
538 r = ctx.repo() 540 r = ctx.repo()
539 status = r.status(ctx.p1(), ctx, 541 return r.status(ctx.p1(), ctx,
540 unknown=unknown, ignored=ignored, clean=True) 542 unknown=unknown, ignored=ignored, clean=True)
541 else: 543 else:
542 status = None 544 return None
543
544 return getset(fullmatchctx(ctx, status), tree)
545 545
546 def prettyformat(tree): 546 def prettyformat(tree):
547 return parser.prettyformat(tree, ('string', 'symbol')) 547 return parser.prettyformat(tree, ('string', 'symbol'))
548 548
549 def loadpredicate(ui, extname, registrarobj): 549 def loadpredicate(ui, extname, registrarobj):