Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/logcmdutil.py @ 45630: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 |
comparison
equal
deleted
inserted
replaced
45629:8fe09005ed88 | 45630:224c786f4fce |
---|---|
708 | 708 |
709 # do not attempt filelog-based traversal, which may be fast but cannot | 709 # do not attempt filelog-based traversal, which may be fast but cannot |
710 # include revisions where files were removed | 710 # include revisions where files were removed |
711 force_changelog_traversal = attr.ib(default=False) # type: bool | 711 force_changelog_traversal = attr.ib(default=False) # type: bool |
712 | 712 |
713 # sort revisions prior to traversal: 'desc', 'topo', or None | |
714 sort_revisions = attr.ib(default=None) # type: Optional[bytes] | |
715 | |
713 # limit number of changes displayed; None means unlimited | 716 # limit number of changes displayed; None means unlimited |
714 limit = attr.ib(default=None) # type: Optional[int] | 717 limit = attr.ib(default=None) # type: Optional[int] |
715 | 718 |
716 | 719 |
717 def parseopts(ui, pats, opts): | 720 def parseopts(ui, pats, opts): |
724 follow = 1 | 727 follow = 1 |
725 elif opts.get(b'follow'): | 728 elif opts.get(b'follow'): |
726 follow = 2 | 729 follow = 2 |
727 else: | 730 else: |
728 follow = 0 | 731 follow = 0 |
732 | |
733 if opts.get(b'graph'): | |
734 if ui.configbool(b'experimental', b'log.topo'): | |
735 sort_revisions = b'topo' | |
736 else: | |
737 sort_revisions = b'desc' | |
738 else: | |
739 sort_revisions = None | |
729 | 740 |
730 return walkopts( | 741 return walkopts( |
731 pats=pats, | 742 pats=pats, |
732 opts=opts, | 743 opts=opts, |
733 revspec=opts.get(b'rev', []), | 744 revspec=opts.get(b'rev', []), |
742 users=opts.get(b'user', []), | 753 users=opts.get(b'user', []), |
743 include_pats=opts.get(b'include', []), | 754 include_pats=opts.get(b'include', []), |
744 exclude_pats=opts.get(b'exclude', []), | 755 exclude_pats=opts.get(b'exclude', []), |
745 follow=follow, | 756 follow=follow, |
746 force_changelog_traversal=bool(opts.get(b'removed')), | 757 force_changelog_traversal=bool(opts.get(b'removed')), |
758 sort_revisions=sort_revisions, | |
747 limit=getlimit(opts), | 759 limit=getlimit(opts), |
748 ) | 760 ) |
749 | 761 |
750 | 762 |
751 def _makematcher(repo, revs, wopts): | 763 def _makematcher(repo, revs, wopts): |
973 | 985 |
974 def filematcher(ctx): | 986 def filematcher(ctx): |
975 return match | 987 return match |
976 | 988 |
977 expr = _makerevset(repo, wopts, slowpath) | 989 expr = _makerevset(repo, wopts, slowpath) |
978 if wopts.opts.get(b'graph'): | 990 if wopts.sort_revisions: |
979 if repo.ui.configbool(b'experimental', b'log.topo'): | 991 assert wopts.sort_revisions in {b'topo', b'desc'} |
992 if wopts.sort_revisions == b'topo': | |
980 if not revs.istopo(): | 993 if not revs.istopo(): |
981 revs = dagop.toposort(revs, repo.changelog.parentrevs) | 994 revs = dagop.toposort(revs, repo.changelog.parentrevs) |
982 # TODO: try to iterate the set lazily | 995 # TODO: try to iterate the set lazily |
983 revs = revset.baseset(list(revs), istopo=True) | 996 revs = revset.baseset(list(revs), istopo=True) |
984 elif not (revs.isdescending() or revs.istopo()): | 997 elif not (revs.isdescending() or revs.istopo()): |