Patchwork [4,of,6] log: extract common part from getgraphlogrevs() and getlogrevs()

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 6, 2015, 2:41 p.m.
Message ID <0bd4619d187669a31547.1423233660@mimosa>
Download mbox | patch
Permalink /patch/7712/
State Accepted
Commit f576addb5b775247b2e6ea207299c48e41954f49
Headers show

Comments

Yuya Nishihara - Feb. 6, 2015, 2:41 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1423149335 -32400
#      Fri Feb 06 00:15:35 2015 +0900
# Node ID 0bd4619d187669a31547539dd975011afda5c85d
# Parent  9897709778e4f046ac4c82de07808505ffa90379
log: extract common part from getgraphlogrevs() and getlogrevs()

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1822,6 +1822,19 @@  def _makelogrevset(repo, pats, opts, rev
         expr = None
     return expr, filematcher
 
+def _logrevs(repo, opts):
+    # Default --rev value depends on --follow but --follow behaviour
+    # depends on revisions resolved from --rev...
+    follow = opts.get('follow') or opts.get('follow_first')
+    if opts.get('rev'):
+        revs = scmutil.revrange(repo, opts['rev'])
+    elif follow:
+        revs = repo.revs('reverse(:.)')
+    else:
+        revs = revset.spanset(repo)
+        revs.reverse()
+    return revs
+
 def getgraphlogrevs(repo, pats, opts):
     """Return (revs, expr, filematcher) where revs is an iterable of
     revision numbers, expr is a revset string built from log options
@@ -1831,17 +1844,7 @@  def getgraphlogrevs(repo, pats, opts):
     filtering the files to be detailed when displaying the revision.
     """
     limit = loglimit(opts)
-    # Default --rev value depends on --follow but --follow behaviour
-    # depends on revisions resolved from --rev...
-    follow = opts.get('follow') or opts.get('follow_first')
-    if opts.get('rev'):
-        revs = scmutil.revrange(repo, opts['rev'])
-    else:
-        if follow:
-            revs = repo.revs('reverse(:.)')
-        else:
-            revs = revset.spanset(repo)
-            revs.reverse()
+    revs = _logrevs(repo, opts)
     if not revs:
         return revset.baseset(), None, None
     expr, filematcher = _makelogrevset(repo, pats, opts, revs)
@@ -1878,16 +1881,7 @@  def getlogrevs(repo, pats, opts):
     filtering the files to be detailed when displaying the revision.
     """
     limit = loglimit(opts)
-    # Default --rev value depends on --follow but --follow behaviour
-    # depends on revisions resolved from --rev...
-    follow = opts.get('follow') or opts.get('follow_first')
-    if opts.get('rev'):
-        revs = scmutil.revrange(repo, opts['rev'])
-    elif follow:
-        revs = repo.revs('reverse(:.)')
-    else:
-        revs = revset.spanset(repo)
-        revs.reverse()
+    revs = _logrevs(repo, opts)
     if not revs:
         return revset.baseset([]), None, None
     expr, filematcher = _makelogrevset(repo, pats, opts, revs)