Patchwork D9317: log: use scmutil.bookmarkrevs to get the revisions of a bookmark

login
register
mail settings
Submitter phabricator
Date Nov. 13, 2020, 1:12 a.m.
Message ID <differential-rev-PHID-DREV-qnca7nf7g5ndi2qrustt-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47592/
State Superseded
Headers show

Comments

phabricator - Nov. 13, 2020, 1:12 a.m.
sebhtml created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9317

AFFECTED FILES
  mercurial/commands.py
  mercurial/logcmdutil.py

CHANGE DETAILS




To: sebhtml, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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,
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