diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4740,14 +4740,21 @@ ) repo = scmutil.unhidehashlikerevs(repo, opts.get(b'rev'), b'nowarn') + walk_opts = logcmdutil.parseopts(ui, pats, opts) revs, differ = logcmdutil.getrevs( - repo, logcmdutil.parseopts(ui, pats, opts) + repo, walk_opts ) if linerange: # TODO: should follow file history from logcmdutil._initialrevs(), # then filter the result by logcmdutil._makerevset() and --limit revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts) + if opts.get(b'bookmark'): + cmdutil.check_at_most_one_arg(opts, b'rev', b'bookmark') + bookmarks = opts.get(b'bookmark') + bookmark = bookmarks[0] + revs, differ = logcmdutil.get_bookmark_revs(repo, bookmark, walk_opts) + getcopies = None if opts.get(b'copies'): endrev = None diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -1021,6 +1021,24 @@ differ._makefilematcher = filematcher 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,