Patchwork [2,of,4] scmutil: extract function that builds revset expr to select bookmark branch

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 1, 2020, 12:50 p.m.
Message ID <3b3f53b5b57f32b10c6e.1606827032@lemosa>
Download mbox | patch
Permalink /patch/47755/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 1, 2020, 12:50 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1606818203 -32400
#      Tue Dec 01 19:23:23 2020 +0900
# Node ID 3b3f53b5b57f32b10c6e5c8aacffab002fd793ea
# Parent  4439db4d98bc5d5d05b709d0886cb81b1347516e
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.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -2304,7 +2304,13 @@  def bookmarkrevs(repo, mark):
 
     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))",