comparison mercurial/fileset.py @ 31189:3c32a3fdfd16

fileset: extract function that builds initial subset from ctx or status This function will be used to recalculate subset when mctx.ctx is switched.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 24 Mar 2015 23:10:49 +0900
parents ec5b56b50e19
children 2f881e7d1ade
comparison
equal deleted inserted replaced
31188:ec5b56b50e19 31189:3c32a3fdfd16
512 for s in tree[1:]: 512 for s in tree[1:]:
513 if _intree(funcs, s): 513 if _intree(funcs, s):
514 return True 514 return True
515 return False 515 return False
516 516
517 def _buildsubset(ctx, status):
518 if status:
519 subset = []
520 for c in status:
521 subset.extend(c)
522 return subset
523 else:
524 return list(ctx.walk(ctx.match([])))
525
517 def getfileset(ctx, expr): 526 def getfileset(ctx, expr):
518 tree = parse(expr) 527 tree = parse(expr)
519 528
520 # do we need status info? 529 # do we need status info?
521 if (_intree(_statuscallers, tree) or 530 if (_intree(_statuscallers, tree) or
526 ignored = _intree(['ignored'], tree) 535 ignored = _intree(['ignored'], tree)
527 536
528 r = ctx.repo() 537 r = ctx.repo()
529 status = r.status(ctx.p1(), ctx, 538 status = r.status(ctx.p1(), ctx,
530 unknown=unknown, ignored=ignored, clean=True) 539 unknown=unknown, ignored=ignored, clean=True)
531 subset = []
532 for c in status:
533 subset.extend(c)
534 else: 540 else:
535 status = None 541 status = None
536 subset = list(ctx.walk(ctx.match([]))) 542
537 543 subset = _buildsubset(ctx, status)
538 return getset(fullmatchctx(ctx, subset, status), tree) 544 return getset(fullmatchctx(ctx, subset, status), tree)
539 545
540 def prettyformat(tree): 546 def prettyformat(tree):
541 return parser.prettyformat(tree, ('string', 'symbol')) 547 return parser.prettyformat(tree, ('string', 'symbol'))
542 548