Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 35543:a7f7eff4ec08
log: merge getlogrevs() and getgraphlogrevs()
cmdutil.graphlog() is updated to receive (revs, filematcher) as arguments
to make sure that opts['graph'] is set when getlogrevs() is invoked.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 04 Jan 2018 10:51:41 +0900 |
parents | 817a3d20dd01 |
children | 8494944940e5 |
comparison
equal
deleted
inserted
replaced
35542:beb667c9880f | 35543:a7f7eff4ec08 |
---|---|
2504 else: | 2504 else: |
2505 revs = smartset.spanset(repo) | 2505 revs = smartset.spanset(repo) |
2506 revs.reverse() | 2506 revs.reverse() |
2507 return revs | 2507 return revs |
2508 | 2508 |
2509 def getgraphlogrevs(repo, pats, opts): | 2509 def getlogrevs(repo, pats, opts): |
2510 """Return (revs, expr, filematcher) where revs is an iterable of | 2510 """Return (revs, expr, filematcher) where revs is an iterable of |
2511 revision numbers, expr is a revset string built from log options | 2511 revision numbers, expr is a revset string built from log options |
2512 and file patterns or None, and used to filter 'revs'. If --stat or | 2512 and file patterns or None, and used to filter 'revs'. If --stat or |
2513 --patch are not passed filematcher is None. Otherwise it is a | 2513 --patch are not passed filematcher is None. Otherwise it is a |
2514 callable taking a revision number and returning a match objects | 2514 callable taking a revision number and returning a match objects |
2517 limit = loglimit(opts) | 2517 limit = loglimit(opts) |
2518 revs = _logrevs(repo, opts) | 2518 revs = _logrevs(repo, opts) |
2519 if not revs: | 2519 if not revs: |
2520 return smartset.baseset(), None, None | 2520 return smartset.baseset(), None, None |
2521 expr, filematcher = _makelogrevset(repo, pats, opts, revs) | 2521 expr, filematcher = _makelogrevset(repo, pats, opts, revs) |
2522 if opts.get('rev'): | 2522 if opts.get('graph') and opts.get('rev'): |
2523 # User-specified revs might be unsorted, but don't sort before | 2523 # User-specified revs might be unsorted, but don't sort before |
2524 # _makelogrevset because it might depend on the order of revs | 2524 # _makelogrevset because it might depend on the order of revs |
2525 if not (revs.isdescending() or revs.istopo()): | 2525 if not (revs.isdescending() or revs.istopo()): |
2526 revs.sort(reverse=True) | 2526 revs.sort(reverse=True) |
2527 if expr: | 2527 if expr: |
2531 limitedrevs = [] | 2531 limitedrevs = [] |
2532 for idx, rev in enumerate(revs): | 2532 for idx, rev in enumerate(revs): |
2533 if idx >= limit: | 2533 if idx >= limit: |
2534 break | 2534 break |
2535 limitedrevs.append(rev) | 2535 limitedrevs.append(rev) |
2536 revs = smartset.baseset(limitedrevs) | |
2537 | |
2538 return revs, expr, filematcher | |
2539 | |
2540 def getlogrevs(repo, pats, opts): | |
2541 """Return (revs, expr, filematcher) where revs is an iterable of | |
2542 revision numbers, expr is a revset string built from log options | |
2543 and file patterns or None, and used to filter 'revs'. If --stat or | |
2544 --patch are not passed filematcher is None. Otherwise it is a | |
2545 callable taking a revision number and returning a match objects | |
2546 filtering the files to be detailed when displaying the revision. | |
2547 """ | |
2548 limit = loglimit(opts) | |
2549 revs = _logrevs(repo, opts) | |
2550 if not revs: | |
2551 return smartset.baseset([]), None, None | |
2552 expr, filematcher = _makelogrevset(repo, pats, opts, revs) | |
2553 if expr: | |
2554 matcher = revset.match(repo.ui, expr) | |
2555 revs = matcher(repo, revs) | |
2556 if limit is not None: | |
2557 limitedrevs = [] | |
2558 for idx, r in enumerate(revs): | |
2559 if limit <= idx: | |
2560 break | |
2561 limitedrevs.append(r) | |
2562 revs = smartset.baseset(limitedrevs) | 2536 revs = smartset.baseset(limitedrevs) |
2563 | 2537 |
2564 return revs, expr, filematcher | 2538 return revs, expr, filematcher |
2565 | 2539 |
2566 def _parselinerangelogopt(repo, opts): | 2540 def _parselinerangelogopt(repo, opts): |
2717 for type, char, width, coldata in itertools.chain([firstedge], edges): | 2691 for type, char, width, coldata in itertools.chain([firstedge], edges): |
2718 graphmod.ascii(ui, state, type, char, lines, coldata) | 2692 graphmod.ascii(ui, state, type, char, lines, coldata) |
2719 lines = [] | 2693 lines = [] |
2720 displayer.close() | 2694 displayer.close() |
2721 | 2695 |
2722 def graphlog(ui, repo, pats, opts): | 2696 def graphlog(ui, repo, revs, filematcher, opts): |
2723 # Parameters are identical to log command ones | 2697 # Parameters are identical to log command ones |
2724 revs, expr, filematcher = getgraphlogrevs(repo, pats, opts) | |
2725 revdag = graphmod.dagwalker(repo, revs) | 2698 revdag = graphmod.dagwalker(repo, revs) |
2726 | 2699 |
2727 getrenamed = None | 2700 getrenamed = None |
2728 if opts.get('copies'): | 2701 if opts.get('copies'): |
2729 endrev = None | 2702 endrev = None |