Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/logcmdutil.py Tue Dec 01 19:23:23 2020 +0900 +++ b/mercurial/logcmdutil.py Tue Dec 01 19:32:36 2020 +0900 @@ -691,6 +691,7 @@ revspec = attr.ib() # type: List[bytes] # miscellaneous queries to filter revisions (see "hg help log" for details) + bookmarks = attr.ib(default=attr.Factory(list)) # type: List[bytes] branches = attr.ib(default=attr.Factory(list)) # type: List[bytes] date = attr.ib(default=None) # type: Optional[bytes] keywords = attr.ib(default=attr.Factory(list)) # type: List[bytes] @@ -746,6 +747,7 @@ pats=pats, opts=opts, revspec=opts.get(b'rev', []), + bookmarks=opts.get(b'bookmark', []), # branch and only_branch are really aliases and must be handled at # the same time branches=opts.get(b'branch', []) + opts.get(b'only_branch', []), @@ -937,6 +939,14 @@ val = [revsetlang.formatspec(revop, v) for v in val] expr.append(revsetlang.formatspec(listop, val)) + if wopts.bookmarks: + expr.append( + revsetlang.formatspec( + b'%lr', + [scmutil.format_bookmark_revspec(v) for v in wopts.bookmarks], + ) + ) + if expr: expr = b'(' + b' and '.join(expr) + b')' else: @@ -1023,26 +1033,6 @@ return revs, differ -def get_bookmark_revs(repo, bookmark, walk_opts): - # type: (Any, bookmark, walk_opts) -> Tuple[smartset.abstractsmartset, Optional[changesetdiffer]] - """Return (revs, differ) where revs is a smartset - - differ is a changesetdiffer with pre-configured file matcher. - """ - revs, filematcher = makewalker(repo, walk_opts) - if not revs: - return revs, None - differ = changesetdiffer() - differ._makefilematcher = filematcher - - if bookmark: - if bookmark not in repo._bookmarks: - raise error.Abort(_(b"bookmark '%s' not found") % bookmark) - revs = scmutil.bookmarkrevs(repo, bookmark) - - return revs, differ - - def _parselinerangeopt(repo, opts): """Parse --line-range log option and return a list of tuples (filename, (fromline, toline)).