# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1516506519 -32400
#      Sun Jan 21 12:48:39 2018 +0900
# Node ID 4d73d231cfcbe6f58355da6d9156f116ebffd0e6
# Parent  85fffc6b5554b64deb39a798fc3f6e2202f90a9b
logcmdutil: drop redundant "log" from function names (API)

A few exceptions:

- s/loglimit/getlimit/ to avoid name conflict
- s/_logrevs/_initialrevs/ to clarify its functionality

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -389,22 +389,20 @@ def overridelog(orig, ui, repo, *pats, *
     # (2) to determine what files to print out diffs for.
     # The magic matchandpats override should be used for case (1) but not for
     # case (2).
-    def overridemakelogfilematcher(repo, pats, opts, badfn=None):
+    def overridemakefilematcher(repo, pats, opts, badfn=None):
         wctx = repo[None]
         match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn)
         return lambda rev: match
 
     oldmatchandpats = installmatchandpatsfn(overridematchandpats)
-    oldmakelogfilematcher = logcmdutil._makenofollowlogfilematcher
-    setattr(logcmdutil, '_makenofollowlogfilematcher',
-            overridemakelogfilematcher)
+    oldmakefilematcher = logcmdutil._makenofollowfilematcher
+    setattr(logcmdutil, '_makenofollowfilematcher', overridemakefilematcher)
 
     try:
         return orig(ui, repo, *pats, **opts)
     finally:
         restorematchandpatsfn()
-        setattr(logcmdutil, '_makenofollowlogfilematcher',
-                oldmakelogfilematcher)
+        setattr(logcmdutil, '_makenofollowfilematcher', oldmakefilematcher)
 
 def overrideverify(orig, ui, repo, *pats, **opts):
     large = opts.pop(r'large', False)
diff --git a/hgext/sparse.py b/hgext/sparse.py
--- a/hgext/sparse.py
+++ b/hgext/sparse.py
@@ -126,7 +126,7 @@ def _setuplog(ui):
     entry[1].append(('', 'sparse', None,
         "limit to changesets affecting the sparse checkout"))
 
-    def _logrevs(orig, repo, opts):
+    def _initialrevs(orig, repo, opts):
         revs = orig(repo, opts)
         if opts.get('sparse'):
             sparsematch = sparse.matcher(repo)
@@ -135,7 +135,7 @@ def _setuplog(ui):
                 return any(f for f in ctx.files() if sparsematch(f))
             revs = revs.filter(ctxmatch)
         return revs
-    extensions.wrapfunction(logcmdutil, '_logrevs', _logrevs)
+    extensions.wrapfunction(logcmdutil, '_initialrevs', _initialrevs)
 
 def _clonesparsecmd(orig, ui, repo, *args, **opts):
     include_pat = opts.get('include')
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -46,17 +46,17 @@ from . import (
 )
 stringio = util.stringio
 
-loglimit = logcmdutil.loglimit
+loglimit = logcmdutil.getlimit
 diffordiffstat = logcmdutil.diffordiffstat
 _changesetlabels = logcmdutil.changesetlabels
 changeset_printer = logcmdutil.changesetprinter
 jsonchangeset = logcmdutil.jsonchangeset
 changeset_templater = logcmdutil.changesettemplater
-logtemplatespec = logcmdutil.logtemplatespec
-makelogtemplater = logcmdutil.makelogtemplater
+logtemplatespec = logcmdutil.templatespec
+makelogtemplater = logcmdutil.maketemplater
 show_changeset = logcmdutil.changesetdisplayer
-getlogrevs = logcmdutil.getlogrevs
-getloglinerangerevs = logcmdutil.getloglinerangerevs
+getlogrevs = logcmdutil.getrevs
+getloglinerangerevs = logcmdutil.getlinerangerevs
 displaygraph = logcmdutil.displaygraph
 graphlog = logcmdutil.graphlog
 checkunsupportedgraphflags = logcmdutil.checkunsupportedgraphflags
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -36,7 +36,7 @@ from . import (
     util,
 )
 
-def loglimit(opts):
+def getlimit(opts):
     """get the log limit according to option -l/--limit"""
     limit = opts.get('limit')
     if limit:
@@ -391,7 +391,7 @@ class changesettemplater(changesetprinte
 
     Note: there are a variety of convenience functions to build a
     changesettemplater for common cases. See functions such as:
-    makelogtemplater, changesetdisplayer, buildcommittemplate, or other
+    maketemplater, changesetdisplayer, buildcommittemplate, or other
     functions that use changesest_templater.
     '''
 
@@ -478,13 +478,13 @@ class changesettemplater(changesetprinte
                 self.footer = templater.stringify(
                     self.t(self._parts['footer'], **props))
 
-def logtemplatespec(tmpl, mapfile):
+def templatespec(tmpl, mapfile):
     if mapfile:
         return formatter.templatespec('changeset', tmpl, mapfile)
     else:
         return formatter.templatespec('', tmpl, None)
 
-def _lookuplogtemplate(ui, tmpl, style):
+def _lookuptemplate(ui, tmpl, style):
     """Find the template matching the given template spec or style
 
     See formatter.lookuptemplate() for details.
@@ -494,7 +494,7 @@ def _lookuplogtemplate(ui, tmpl, style):
     if not tmpl and not style: # template are stronger than style
         tmpl = ui.config('ui', 'logtemplate')
         if tmpl:
-            return logtemplatespec(templater.unquotestring(tmpl), None)
+            return templatespec(templater.unquotestring(tmpl), None)
         else:
             style = util.expandpath(ui.config('ui', 'style'))
 
@@ -505,17 +505,17 @@ def _lookuplogtemplate(ui, tmpl, style):
                        or templater.templatepath(mapfile))
             if mapname:
                 mapfile = mapname
-        return logtemplatespec(None, mapfile)
+        return templatespec(None, mapfile)
 
     if not tmpl:
-        return logtemplatespec(None, None)
+        return templatespec(None, None)
 
     return formatter.lookuptemplate(ui, 'changeset', tmpl)
 
-def makelogtemplater(ui, repo, tmpl, buffered=False):
+def maketemplater(ui, repo, tmpl, buffered=False):
     """Create a changesettemplater from a literal template 'tmpl'
     byte-string."""
-    spec = logtemplatespec(tmpl, None)
+    spec = templatespec(tmpl, None)
     return changesettemplater(ui, repo, spec, buffered=buffered)
 
 def changesetdisplayer(ui, repo, opts, buffered=False):
@@ -537,14 +537,14 @@ def changesetdisplayer(ui, repo, opts, b
     if opts.get('template') == 'json':
         return jsonchangeset(ui, repo, match, opts, buffered)
 
-    spec = _lookuplogtemplate(ui, opts.get('template'), opts.get('style'))
+    spec = _lookuptemplate(ui, opts.get('template'), opts.get('style'))
 
     if not spec.ref and not spec.tmpl and not spec.mapfile:
         return changesetprinter(ui, repo, match, opts, buffered)
 
     return changesettemplater(ui, repo, spec, match, opts, buffered)
 
-def _makelogmatcher(repo, revs, pats, opts):
+def _makematcher(repo, revs, pats, opts):
     """Build matcher and expanded patterns from log options
 
     If --follow, revs are the revisions to follow from.
@@ -625,7 +625,7 @@ def _fileancestors(repo, revs, match, fo
             yield rev
     return smartset.generatorset(revgen(), iterasc=False), filematcher
 
-def _makenofollowlogfilematcher(repo, pats, opts):
+def _makenofollowfilematcher(repo, pats, opts):
     '''hook for extensions to override the filematcher for non-follow cases'''
     return None
 
@@ -641,7 +641,7 @@ def _makenofollowlogfilematcher(repo, pa
     'user':             ('user(%s)', '%lr'),
 }
 
-def _makelogrevset(repo, match, pats, slowpath, opts):
+def _makerevset(repo, match, pats, slowpath, opts):
     """Return a revset string built from log options and file patterns"""
     opts = dict(opts)
     # follow or not follow?
@@ -694,7 +694,7 @@ def _makelogrevset(repo, match, pats, sl
         expr = None
     return expr
 
-def _logrevs(repo, opts):
+def _initialrevs(repo, opts):
     """Return the initial set of revisions to be filtered or followed"""
     follow = opts.get('follow') or opts.get('follow_first')
     if opts.get('rev'):
@@ -708,7 +708,7 @@ def _logrevs(repo, opts):
         revs.reverse()
     return revs
 
-def getlogrevs(repo, pats, opts):
+def getrevs(repo, pats, opts):
     """Return (revs, filematcher) where revs is a smartset
 
     filematcher is a callable taking a revision number and returning a match
@@ -716,11 +716,11 @@ def getlogrevs(repo, pats, opts):
     """
     follow = opts.get('follow') or opts.get('follow_first')
     followfirst = opts.get('follow_first')
-    limit = loglimit(opts)
-    revs = _logrevs(repo, opts)
+    limit = getlimit(opts)
+    revs = _initialrevs(repo, opts)
     if not revs:
         return smartset.baseset(), None
-    match, pats, slowpath = _makelogmatcher(repo, revs, pats, opts)
+    match, pats, slowpath = _makematcher(repo, revs, pats, opts)
     filematcher = None
     if follow:
         if slowpath or match.always():
@@ -729,15 +729,15 @@ def getlogrevs(repo, pats, opts):
             revs, filematcher = _fileancestors(repo, revs, match, followfirst)
         revs.reverse()
     if filematcher is None:
-        filematcher = _makenofollowlogfilematcher(repo, pats, opts)
+        filematcher = _makenofollowfilematcher(repo, pats, opts)
     if filematcher is None:
         def filematcher(rev):
             return match
 
-    expr = _makelogrevset(repo, match, pats, slowpath, opts)
+    expr = _makerevset(repo, match, pats, slowpath, opts)
     if opts.get('graph') and opts.get('rev'):
         # User-specified revs might be unsorted, but don't sort before
-        # _makelogrevset because it might depend on the order of revs
+        # _makerevset because it might depend on the order of revs
         if not (revs.isdescending() or revs.istopo()):
             revs.sort(reverse=True)
     if expr:
@@ -747,7 +747,7 @@ def getlogrevs(repo, pats, opts):
         revs = revs.slice(0, limit)
     return revs, filematcher
 
-def _parselinerangelogopt(repo, opts):
+def _parselinerangeopt(repo, opts):
     """Parse --line-range log option and return a list of tuples (filename,
     (fromline, toline)).
     """
@@ -767,7 +767,7 @@ def _parselinerangelogopt(repo, opts):
             (fname, util.processlinerange(fromline, toline)))
     return linerangebyfname
 
-def getloglinerangerevs(repo, userrevs, opts):
+def getlinerangerevs(repo, userrevs, opts):
     """Return (revs, filematcher, hunksfilter).
 
     "revs" are revisions obtained by processing "line-range" log options and
@@ -785,7 +785,7 @@ def getloglinerangerevs(repo, userrevs, 
 
     # Two-levels map of "rev -> file ctx -> [line range]".
     linerangesbyrev = {}
-    for fname, (fromline, toline) in _parselinerangelogopt(repo, opts):
+    for fname, (fromline, toline) in _parselinerangeopt(repo, opts):
         if fname not in wctx:
             raise error.Abort(_('cannot follow file not in parent '
                                 'revision: "%s"') % fname)
@@ -926,7 +926,7 @@ def checkunsupportedgraphflags(pats, opt
                              % op.replace("_", "-"))
 
 def graphrevs(repo, nodes, opts):
-    limit = loglimit(opts)
+    limit = getlimit(opts)
     nodes.reverse()
     if limit is not None:
         nodes = nodes[:limit]
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -93,11 +93,11 @@ o  (0) root
   > )
   > 
   > def logrevset(repo, pats, opts):
-  >     revs = logcmdutil._logrevs(repo, opts)
+  >     revs = logcmdutil._initialrevs(repo, opts)
   >     if not revs:
   >         return None
-  >     match, pats, slowpath = logcmdutil._makelogmatcher(repo, revs, pats, 
opts)
-  >     return logcmdutil._makelogrevset(repo, match, pats, slowpath, opts)
+  >     match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts)
+  >     return logcmdutil._makerevset(repo, match, pats, slowpath, opts)
   > 
   > def uisetup(ui):
   >     def printrevset(orig, repo, pats, opts):
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to