Mercurial > hg
changeset 45627:224c786f4fce
log: move --graph and topo sort options to walkopts
This is the last opts.get() found in getrevs(). It might be better to define
an enum, but for now, it is just a string.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 12 Sep 2020 22:42:58 +0900 |
parents | 8fe09005ed88 |
children | 7f033a587414 |
files | mercurial/logcmdutil.py |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/logcmdutil.py Sat Sep 12 22:03:53 2020 +0900 +++ b/mercurial/logcmdutil.py Sat Sep 12 22:42:58 2020 +0900 @@ -710,6 +710,9 @@ # include revisions where files were removed force_changelog_traversal = attr.ib(default=False) # type: bool + # sort revisions prior to traversal: 'desc', 'topo', or None + sort_revisions = attr.ib(default=None) # type: Optional[bytes] + # limit number of changes displayed; None means unlimited limit = attr.ib(default=None) # type: Optional[int] @@ -727,6 +730,14 @@ else: follow = 0 + if opts.get(b'graph'): + if ui.configbool(b'experimental', b'log.topo'): + sort_revisions = b'topo' + else: + sort_revisions = b'desc' + else: + sort_revisions = None + return walkopts( pats=pats, opts=opts, @@ -744,6 +755,7 @@ exclude_pats=opts.get(b'exclude', []), follow=follow, force_changelog_traversal=bool(opts.get(b'removed')), + sort_revisions=sort_revisions, limit=getlimit(opts), ) @@ -975,8 +987,9 @@ return match expr = _makerevset(repo, wopts, slowpath) - if wopts.opts.get(b'graph'): - if repo.ui.configbool(b'experimental', b'log.topo'): + if wopts.sort_revisions: + assert wopts.sort_revisions in {b'topo', b'desc'} + if wopts.sort_revisions == b'topo': if not revs.istopo(): revs = dagop.toposort(revs, repo.changelog.parentrevs) # TODO: try to iterate the set lazily