diff mercurial/logcmdutil.py @ 45915:0aa118f18d4b

log: add bookmark option to "hg log" Before pushing a bookmark with "hg push origin -B 'my-topic'", it is useful to inspect the list of commits that are ancestors of the bookmark. By relying on scmutil.bookmarkrevs(), "hg log -B topic" has the same bookmark semantics found in other commands like hg export, hg email, hg strip. Differential Revision: https://phab.mercurial-scm.org/D9341
author Sebastien Boisvert <sebhtml@protonmail.com>
date Tue, 17 Nov 2020 21:30:50 -0500
parents 1f7c077e0640
children 89a2afe31e82
line wrap: on
line diff
--- a/mercurial/logcmdutil.py	Sat Nov 21 16:55:07 2020 -0500
+++ b/mercurial/logcmdutil.py	Tue Nov 17 21:30:50 2020 -0500
@@ -1024,6 +1024,26 @@
     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)).