scmutil: extract function that builds revset expr to select bookmark branch
authorYuya Nishihara <yuya@tcha.org>
Tue, 01 Dec 2020 19:23:23 +0900
changeset 46040 9ee791f3278f
parent 46039 b9ebe0bfed4e
child 46041 9c0db3671008
scmutil: extract function that builds revset expr to select bookmark branch This is needed to process "log -B" option properly. "log" options have to be translated to a revset expression, not to an evaluated set.
mercurial/scmutil.py
--- a/mercurial/scmutil.py	Tue Dec 01 19:46:01 2020 +0900
+++ b/mercurial/scmutil.py	Tue Dec 01 19:23:23 2020 +0900
@@ -2304,7 +2304,13 @@
 
     If the bookmarked revision isn't a head, an empty set will be returned.
     """
-    return repo.revs(
+    return repo.revs(format_bookmark_revspec(mark))
+
+
+def format_bookmark_revspec(mark):
+    """Build a revset expression to select revisions reachable by a given
+    bookmark"""
+    return revsetlang.formatspec(
         b"ancestors(bookmark(%s)) - "
         b"ancestors(head() and not bookmark(%s)) - "
         b"ancestors(bookmark() and not bookmark(%s))",