Mercurial > public > mercurial-scm > hg
comparison mercurial/logcmdutil.py @ 46041:9c0db3671008
log: do not override other filtering and sorting options by --bookmark
This basically reimplements 0aa118f18d4b 'log: add bookmark option to
"hg log"'. Before, any other filtering options but --rev were ignored.
-G didn't work either since the ordering constraint wasn't enforced.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 01 Dec 2020 19:32:36 +0900 |
parents | 89a2afe31e82 |
children | 1bf2b44c4007 |
comparison
equal
deleted
inserted
replaced
46040:9ee791f3278f | 46041:9c0db3671008 |
---|---|
689 # a list of revset expressions to be traversed; if follow, it specifies | 689 # a list of revset expressions to be traversed; if follow, it specifies |
690 # the start revisions | 690 # the start revisions |
691 revspec = attr.ib() # type: List[bytes] | 691 revspec = attr.ib() # type: List[bytes] |
692 | 692 |
693 # miscellaneous queries to filter revisions (see "hg help log" for details) | 693 # miscellaneous queries to filter revisions (see "hg help log" for details) |
694 bookmarks = attr.ib(default=attr.Factory(list)) # type: List[bytes] | |
694 branches = attr.ib(default=attr.Factory(list)) # type: List[bytes] | 695 branches = attr.ib(default=attr.Factory(list)) # type: List[bytes] |
695 date = attr.ib(default=None) # type: Optional[bytes] | 696 date = attr.ib(default=None) # type: Optional[bytes] |
696 keywords = attr.ib(default=attr.Factory(list)) # type: List[bytes] | 697 keywords = attr.ib(default=attr.Factory(list)) # type: List[bytes] |
697 no_merges = attr.ib(default=False) # type: bool | 698 no_merges = attr.ib(default=False) # type: bool |
698 only_merges = attr.ib(default=False) # type: bool | 699 only_merges = attr.ib(default=False) # type: bool |
744 | 745 |
745 return walkopts( | 746 return walkopts( |
746 pats=pats, | 747 pats=pats, |
747 opts=opts, | 748 opts=opts, |
748 revspec=opts.get(b'rev', []), | 749 revspec=opts.get(b'rev', []), |
750 bookmarks=opts.get(b'bookmark', []), | |
749 # branch and only_branch are really aliases and must be handled at | 751 # branch and only_branch are really aliases and must be handled at |
750 # the same time | 752 # the same time |
751 branches=opts.get(b'branch', []) + opts.get(b'only_branch', []), | 753 branches=opts.get(b'branch', []) + opts.get(b'only_branch', []), |
752 date=opts.get(b'date'), | 754 date=opts.get(b'date'), |
753 keywords=opts.get(b'keyword', []), | 755 keywords=opts.get(b'keyword', []), |
935 else: | 937 else: |
936 if revop: | 938 if revop: |
937 val = [revsetlang.formatspec(revop, v) for v in val] | 939 val = [revsetlang.formatspec(revop, v) for v in val] |
938 expr.append(revsetlang.formatspec(listop, val)) | 940 expr.append(revsetlang.formatspec(listop, val)) |
939 | 941 |
942 if wopts.bookmarks: | |
943 expr.append( | |
944 revsetlang.formatspec( | |
945 b'%lr', | |
946 [scmutil.format_bookmark_revspec(v) for v in wopts.bookmarks], | |
947 ) | |
948 ) | |
949 | |
940 if expr: | 950 if expr: |
941 expr = b'(' + b' and '.join(expr) + b')' | 951 expr = b'(' + b' and '.join(expr) + b')' |
942 else: | 952 else: |
943 expr = None | 953 expr = None |
944 return expr | 954 return expr |
1018 revs, filematcher = makewalker(repo, wopts) | 1028 revs, filematcher = makewalker(repo, wopts) |
1019 if not revs: | 1029 if not revs: |
1020 return revs, None | 1030 return revs, None |
1021 differ = changesetdiffer() | 1031 differ = changesetdiffer() |
1022 differ._makefilematcher = filematcher | 1032 differ._makefilematcher = filematcher |
1023 return revs, differ | |
1024 | |
1025 | |
1026 def get_bookmark_revs(repo, bookmark, walk_opts): | |
1027 # type: (Any, bookmark, walk_opts) -> Tuple[smartset.abstractsmartset, Optional[changesetdiffer]] | |
1028 """Return (revs, differ) where revs is a smartset | |
1029 | |
1030 differ is a changesetdiffer with pre-configured file matcher. | |
1031 """ | |
1032 revs, filematcher = makewalker(repo, walk_opts) | |
1033 if not revs: | |
1034 return revs, None | |
1035 differ = changesetdiffer() | |
1036 differ._makefilematcher = filematcher | |
1037 | |
1038 if bookmark: | |
1039 if bookmark not in repo._bookmarks: | |
1040 raise error.Abort(_(b"bookmark '%s' not found") % bookmark) | |
1041 revs = scmutil.bookmarkrevs(repo, bookmark) | |
1042 | |
1043 return revs, differ | 1033 return revs, differ |
1044 | 1034 |
1045 | 1035 |
1046 def _parselinerangeopt(repo, opts): | 1036 def _parselinerangeopt(repo, opts): |
1047 """Parse --line-range log option and return a list of tuples (filename, | 1037 """Parse --line-range log option and return a list of tuples (filename, |