Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 21127:69402eb72115
log: changed implementation to use graphlog code
Now that revsets work in a lazy way, log code can be changed to parse every
option into a revset and then evaluate it lazily.
Now expressions like
"hg log -b default -b ."
are converted into a revset using the same code as graphlog.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Fri, 28 Feb 2014 15:10:56 -0800 |
parents | e5ad36a845af |
children | 1a833fcf5a14 3666331164bb |
comparison
equal
deleted
inserted
replaced
21126:99b5eaf372a7 | 21127:69402eb72115 |
---|---|
1667 limitedrevs = revset.baseset() | 1667 limitedrevs = revset.baseset() |
1668 for idx, rev in enumerate(revs): | 1668 for idx, rev in enumerate(revs): |
1669 if idx >= limit: | 1669 if idx >= limit: |
1670 break | 1670 break |
1671 limitedrevs.append(rev) | 1671 limitedrevs.append(rev) |
1672 revs = limitedrevs | |
1673 | |
1674 return revs, expr, filematcher | |
1675 | |
1676 def getlogrevs(repo, pats, opts): | |
1677 """Return (revs, expr, filematcher) where revs is an iterable of | |
1678 revision numbers, expr is a revset string built from log options | |
1679 and file patterns or None, and used to filter 'revs'. If --stat or | |
1680 --patch are not passed filematcher is None. Otherwise it is a | |
1681 callable taking a revision number and returning a match objects | |
1682 filtering the files to be detailed when displaying the revision. | |
1683 """ | |
1684 limit = loglimit(opts) | |
1685 # Default --rev value depends on --follow but --follow behaviour | |
1686 # depends on revisions resolved from --rev... | |
1687 follow = opts.get('follow') or opts.get('follow_first') | |
1688 if opts.get('rev'): | |
1689 revs = scmutil.revrange(repo, opts['rev']) | |
1690 elif follow: | |
1691 revs = revset.baseset(repo.revs('reverse(:.)')) | |
1692 else: | |
1693 revs = revset.spanset(repo) | |
1694 revs.reverse() | |
1695 if not revs: | |
1696 return revset.baseset([]), None, None | |
1697 expr, filematcher = _makelogrevset(repo, pats, opts, revs) | |
1698 if expr: | |
1699 # Revset matchers often operate faster on revisions in changelog | |
1700 # order, because most filters deal with the changelog. | |
1701 if not opts.get('rev'): | |
1702 revs.reverse() | |
1703 matcher = revset.match(repo.ui, expr) | |
1704 # Revset matches can reorder revisions. "A or B" typically returns | |
1705 # returns the revision matching A then the revision matching B. Sort | |
1706 # again to fix that. | |
1707 revs = matcher(repo, revs) | |
1708 if not opts.get('rev'): | |
1709 revs.sort(reverse=True) | |
1710 if limit is not None: | |
1711 count = 0 | |
1712 limitedrevs = revset.baseset([]) | |
1713 it = iter(revs) | |
1714 while count < limit: | |
1715 try: | |
1716 limitedrevs.append(it.next()) | |
1717 except (StopIteration): | |
1718 break | |
1719 count += 1 | |
1672 revs = limitedrevs | 1720 revs = limitedrevs |
1673 | 1721 |
1674 return revs, expr, filematcher | 1722 return revs, expr, filematcher |
1675 | 1723 |
1676 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None, | 1724 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None, |