changeset 14322:a90131b85fd8

scmutil: drop aliases in cmdutil for match functions
author Matt Mackall <mpm@selenic.com>
date Fri, 13 May 2011 14:58:24 -0500
parents 003d63bb4fa5
children a79fea6b3e77
files contrib/perf.py hgext/churn.py hgext/extdiff.py hgext/hgk.py hgext/keyword.py hgext/mq.py hgext/purge.py mercurial/cmdutil.py mercurial/commands.py tests/autodiff.py
diffstat 10 files changed, 51 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Fri May 13 14:48:48 2011 -0500
+++ b/contrib/perf.py	Fri May 13 14:58:24 2011 -0500
@@ -1,7 +1,7 @@
 # perf.py - performance test routines
 '''helper extension to measure performance'''
 
-from mercurial import cmdutil, match, commands
+from mercurial import cmdutil, scmutil, match, commands
 import time, os, sys
 
 def timer(func, title=None):
@@ -31,11 +31,11 @@
 
 def perfwalk(ui, repo, *pats):
     try:
-        m = cmdutil.match(repo, pats, {})
+        m = scmutil.match(repo, pats, {})
         timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
     except:
         try:
-            m = cmdutil.match(repo, pats, {})
+            m = scmutil.match(repo, pats, {})
             timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)]))
         except:
             timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
--- a/hgext/churn.py	Fri May 13 14:48:48 2011 -0500
+++ b/hgext/churn.py	Fri May 13 14:58:24 2011 -0500
@@ -9,7 +9,7 @@
 '''command to display statistics about repository history'''
 
 from mercurial.i18n import _
-from mercurial import patch, cmdutil, util, templater, commands
+from mercurial import patch, cmdutil, scmutil, util, templater, commands
 import os
 import time, datetime
 
@@ -24,7 +24,7 @@
 
 def changedlines(ui, repo, ctx1, ctx2, fns):
     added, removed = 0, 0
-    fmatch = cmdutil.matchfiles(repo, fns)
+    fmatch = scmutil.matchfiles(repo, fns)
     diff = ''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
     for l in diff.split('\n'):
         if l.startswith("+") and not l.startswith("+++ "):
@@ -54,7 +54,7 @@
     if opts.get('date'):
         df = util.matchdate(opts['date'])
 
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     def prep(ctx, fns):
         rev = ctx.rev()
         if df and not df(ctx.date()[0]): # doesn't match date format
--- a/hgext/extdiff.py	Fri May 13 14:48:48 2011 -0500
+++ b/hgext/extdiff.py	Fri May 13 14:58:24 2011 -0500
@@ -62,7 +62,7 @@
 
 from mercurial.i18n import _
 from mercurial.node import short, nullid
-from mercurial import cmdutil, scmutil, util, commands, encoding
+from mercurial import scmutil, scmutil, util, commands, encoding
 import os, shlex, shutil, tempfile, re
 
 def snapshot(ui, repo, files, node, tmproot):
@@ -137,7 +137,7 @@
         if node1b == nullid:
             do3way = False
 
-    matcher = cmdutil.match(repo, pats, opts)
+    matcher = scmutil.match(repo, pats, opts)
     mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher)[:3])
     if do3way:
         mod_b, add_b, rem_b = map(set, repo.status(node1b, node2, matcher)[:3])
--- a/hgext/hgk.py	Fri May 13 14:48:48 2011 -0500
+++ b/hgext/hgk.py	Fri May 13 14:58:24 2011 -0500
@@ -35,7 +35,7 @@
 '''
 
 import os
-from mercurial import commands, util, patch, revlog, cmdutil
+from mercurial import commands, util, patch, revlog, scmutil
 from mercurial.node import nullid, nullrev, short
 from mercurial.i18n import _
 
@@ -45,7 +45,7 @@
         assert node2 is not None
         mmap = repo[node1].manifest()
         mmap2 = repo[node2].manifest()
-        m = cmdutil.match(repo, files)
+        m = scmutil.match(repo, files)
         modified, added, removed  = repo.status(node1, node2, m)[:3]
         empty = short(nullid)
 
@@ -81,7 +81,7 @@
         if opts['patch']:
             if opts['pretty']:
                 catcommit(ui, repo, node2, "")
-            m = cmdutil.match(repo, files)
+            m = scmutil.match(repo, files)
             chunks = patch.diff(repo, node1, node2, match=m,
                                 opts=patch.diffopts(ui, {'git': True}))
             for chunk in chunks:
--- a/hgext/keyword.py	Fri May 13 14:48:48 2011 -0500
+++ b/hgext/keyword.py	Fri May 13 14:58:24 2011 -0500
@@ -326,7 +326,7 @@
     '''Bails out if [keyword] configuration is not active.
     Returns status of working directory.'''
     if kwt:
-        return repo.status(match=cmdutil.match(repo, pats, opts), clean=True,
+        return repo.status(match=scmutil.match(repo, pats, opts), clean=True,
                            unknown=opts.get('unknown') or opts.get('all'))
     if ui.configitems('keyword'):
         raise util.Abort(_('[keyword] patterns cannot match'))
--- a/hgext/mq.py	Fri May 13 14:48:48 2011 -0500
+++ b/hgext/mq.py	Fri May 13 14:58:24 2011 -0500
@@ -46,7 +46,7 @@
 from mercurial.node import bin, hex, short, nullid, nullrev
 from mercurial.lock import release
 from mercurial import commands, cmdutil, hg, scmutil, util, revset
-from mercurial import repair, extensions, url, error, scmutil
+from mercurial import repair, extensions, url, error
 from mercurial import patch as patchmod
 import os, sys, re, errno, shutil
 
@@ -519,7 +519,7 @@
     def printdiff(self, repo, diffopts, node1, node2=None, files=None,
                   fp=None, changes=None, opts={}):
         stat = opts.get('stat')
-        m = cmdutil.match(repo, files, opts)
+        m = scmutil.match(repo, files, opts)
         cmdutil.diffordiffstat(self.ui, repo, diffopts, node1, node2,  m,
                                changes, stat, fp)
 
@@ -711,7 +711,7 @@
                 p1, p2 = repo.dirstate.parents()
                 repo.dirstate.setparents(p1, merge)
 
-            match = cmdutil.matchfiles(repo, files or [])
+            match = scmutil.matchfiles(repo, files or [])
             n = repo.commit(message, ph.user, ph.date, match=match, force=True)
 
             if n is None:
@@ -898,7 +898,7 @@
         if opts.get('include') or opts.get('exclude') or pats:
             if inclsubs:
                 pats = list(pats or []) + inclsubs
-            match = cmdutil.match(repo, pats, opts)
+            match = scmutil.match(repo, pats, opts)
             # detect missing files in pats
             def badfn(f, msg):
                 if f != '.hgsubstate': # .hgsubstate is auto-created
@@ -907,7 +907,7 @@
             m, a, r, d = repo.status(match=match)[:4]
         else:
             m, a, r, d = self.check_localchanges(repo, force=True)
-            match = cmdutil.matchfiles(repo, m + a + r + inclsubs)
+            match = scmutil.matchfiles(repo, m + a + r + inclsubs)
         if len(repo[None].parents()) > 1:
             raise util.Abort(_('cannot manage merge changesets'))
         commitfiles = m + a + r
@@ -1379,17 +1379,17 @@
             changes = repo.changelog.read(top)
             man = repo.manifest.read(changes[0])
             aaa = aa[:]
-            matchfn = cmdutil.match(repo, pats, opts)
+            matchfn = scmutil.match(repo, pats, opts)
             # in short mode, we only diff the files included in the
             # patch already plus specified files
             if opts.get('short'):
                 # if amending a patch, we start with existing
                 # files plus specified files - unfiltered
-                match = cmdutil.matchfiles(repo, mm + aa + dd + matchfn.files())
+                match = scmutil.matchfiles(repo, mm + aa + dd + matchfn.files())
                 # filter with inc/exl options
-                matchfn = cmdutil.match(repo, opts=opts)
+                matchfn = scmutil.match(repo, opts=opts)
             else:
-                match = cmdutil.matchall(repo)
+                match = scmutil.matchall(repo)
             m, a, r, d = repo.status(match=match)[:4]
             mm = set(mm)
             aa = set(aa)
@@ -1427,7 +1427,7 @@
             r = list(dd)
             a = list(aa)
             c = [filter(matchfn, l) for l in (m, a, r)]
-            match = cmdutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs))
+            match = scmutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs))
             chunks = patchmod.diff(repo, patchparent, match=match,
                                 changes=c, opts=diffopts)
             for chunk in chunks:
--- a/hgext/purge.py	Fri May 13 14:48:48 2011 -0500
+++ b/hgext/purge.py	Fri May 13 14:58:24 2011 -0500
@@ -25,7 +25,7 @@
 
 '''command to delete untracked files from the working directory'''
 
-from mercurial import util, commands, cmdutil
+from mercurial import util, commands, cmdutil, scmutil
 from mercurial.i18n import _
 import os, stat
 
@@ -96,7 +96,7 @@
             os.remove(path)
 
     directories = []
-    match = cmdutil.match(repo, dirs, opts)
+    match = scmutil.match(repo, dirs, opts)
     match.dir = directories.append
     status = repo.status(match=match, ignored=opts['all'], unknown=True)
 
--- a/mercurial/cmdutil.py	Fri May 13 14:48:48 2011 -0500
+++ b/mercurial/cmdutil.py	Fri May 13 14:58:24 2011 -0500
@@ -12,10 +12,6 @@
 import match as matchmod
 import subrepo
 
-match = scmutil.match
-matchall = scmutil.matchall
-matchfiles = scmutil.matchfiles
-
 def parsealiases(cmd):
     return cmd.lstrip("^").split("|")
 
@@ -188,7 +184,7 @@
     def walkpat(pat):
         srcs = []
         badstates = after and '?' or '?r'
-        m = match(repo, [pat], opts, globbed=True)
+        m = scmutil.match(repo, [pat], opts, globbed=True)
         for abs in repo.walk(m):
             state = repo.dirstate[abs]
             rel = m.rel(abs)
@@ -803,7 +799,7 @@
     # options
     patch = False
     if opts.get('patch') or opts.get('stat'):
-        patch = matchall(repo)
+        patch = scmutil.matchall(repo)
 
     tmpl = opts.get('template')
     style = None
@@ -844,7 +840,7 @@
     """Find the tipmost changeset that matches the given date spec"""
 
     df = util.matchdate(date)
-    m = matchall(repo)
+    m = scmutil.matchall(repo)
     results = {}
 
     def prep(ctx, fns):
@@ -1135,7 +1131,7 @@
     if opts.get('addremove'):
         scmutil.addremove(repo, pats, opts)
 
-    return commitfunc(ui, repo, message, match(repo, pats, opts), opts)
+    return commitfunc(ui, repo, message, scmutil.match(repo, pats, opts), opts)
 
 def commiteditor(repo, ctx, subs):
     if ctx.description():
--- a/mercurial/commands.py	Fri May 13 14:48:48 2011 -0500
+++ b/mercurial/commands.py	Fri May 13 14:58:24 2011 -0500
@@ -161,7 +161,7 @@
     Returns 0 if all files are successfully added.
     """
 
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
                            opts.get('subrepos'), prefix="")
     return rejected and 1 or 0
@@ -262,7 +262,7 @@
         raise util.Abort("%s: %s" % (x, y))
 
     ctx = scmutil.revsingle(repo, opts.get('rev'))
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     m.bad = bad
     follow = not opts.get('no_follow')
     for abs in ctx.walk(m):
@@ -341,7 +341,7 @@
             prefix = os.path.basename(repo.root) + '-%h'
 
     prefix = cmdutil.makefilename(repo, prefix, node)
-    matchfn = cmdutil.match(repo, [], opts)
+    matchfn = scmutil.match(repo, [], opts)
     archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
                      matchfn, prefix, subrepos=opts.get('subrepos'))
 
@@ -937,7 +937,7 @@
     """
     ctx = scmutil.revsingle(repo, opts.get('rev'))
     err = 1
-    m = cmdutil.match(repo, (file1,) + pats, opts)
+    m = scmutil.match(repo, (file1,) + pats, opts)
     for abs in ctx.walk(m):
         fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
                                  pathname=abs)
@@ -1084,7 +1084,7 @@
 
     node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
     if not node:
-        stat = repo.status(match=cmdutil.match(repo, pats, opts))
+        stat = repo.status(match=scmutil.match(repo, pats, opts))
         if stat[3]:
             ui.status(_("nothing changed (%d missing files, see 'hg status')\n")
                       % len(stat[3]))
@@ -1845,7 +1845,7 @@
     """dump rename information"""
 
     ctx = scmutil.revsingle(repo, opts.get('rev'))
-    m = cmdutil.match(repo, (file1,) + pats, opts)
+    m = scmutil.match(repo, (file1,) + pats, opts)
     for abs in ctx.walk(m):
         fctx = ctx[abs]
         o = fctx.filelog().renamed(fctx.filenode())
@@ -2073,7 +2073,7 @@
 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'))
 def debugwalk(ui, repo, *pats, **opts):
     """show how files match on given patterns"""
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     items = list(repo.walk(m))
     if not items:
         return
@@ -2159,7 +2159,7 @@
         node1, node2 = node2, node1
 
     diffopts = patch.diffopts(ui, opts)
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
                            listsubrepos=opts.get('subrepos'))
 
@@ -2239,7 +2239,7 @@
     if not pats:
         raise util.Abort(_('no files specified'))
 
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     s = repo.status(match=m, clean=True)
     forget = sorted(s[0] + s[1] + s[3] + s[6])
     errs = 0
@@ -2404,7 +2404,7 @@
 
     skip = {}
     revfiles = {}
-    matchfn = cmdutil.match(repo, pats, opts)
+    matchfn = scmutil.match(repo, pats, opts)
     found = False
     follow = opts.get('follow')
 
@@ -3100,7 +3100,7 @@
                 if opts.get('exact'):
                     m = None
                 else:
-                    m = cmdutil.matchfiles(repo, files or [])
+                    m = scmutil.matchfiles(repo, files or [])
                 n = repo.commit(message, opts.get('user') or user,
                                 opts.get('date') or date, match=m,
                                 editor=cmdutil.commiteditor)
@@ -3238,7 +3238,7 @@
     rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
 
     ret = 1
-    m = cmdutil.match(repo, pats, opts, default='relglob')
+    m = scmutil.match(repo, pats, opts, default='relglob')
     m.bad = lambda x, y: False
     for abs in repo[rev].walk(m):
         if not rev and abs not in repo.dirstate:
@@ -3306,7 +3306,7 @@
     Returns 0 on success.
     """
 
-    matchfn = cmdutil.match(repo, pats, opts)
+    matchfn = scmutil.match(repo, pats, opts)
     limit = cmdutil.loglimit(opts)
     count = 0
 
@@ -3359,7 +3359,7 @@
         if opts.get('patch') or opts.get('stat'):
             if opts.get('follow') or opts.get('follow_first'):
                 # note: this might be wrong when following through merges
-                revmatchfn = cmdutil.match(repo, fns, default='path')
+                revmatchfn = scmutil.match(repo, fns, default='path')
             else:
                 revmatchfn = matchfn
 
@@ -3546,7 +3546,7 @@
     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
 
     if file_:
-        m = cmdutil.match(repo, (file_,), opts)
+        m = scmutil.match(repo, (file_,), opts)
         if m.anypats() or len(m.files()) != 1:
             raise util.Abort(_('can only specify an explicit filename'))
         file_ = m.files()[0]
@@ -3853,7 +3853,7 @@
     if not pats and not after:
         raise util.Abort(_('no files specified'))
 
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     s = repo.status(match=m, clean=True)
     modified, added, deleted, clean = s[0], s[1], s[3], s[6]
 
@@ -3973,7 +3973,7 @@
                            'use --all to remerge all files'))
 
     ms = mergemod.mergestate(repo)
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     ret = 0
 
     for f in ms:
@@ -4092,7 +4092,7 @@
     try:
         # walk dirstate.
 
-        m = cmdutil.match(repo, pats, opts)
+        m = scmutil.match(repo, pats, opts)
         m.bad = lambda x, y: False
         for abs in repo.walk(m):
             names[abs] = m.rel(abs), m.exact(abs)
@@ -4108,13 +4108,13 @@
                     return
             ui.warn("%s: %s\n" % (m.rel(path), msg))
 
-        m = cmdutil.match(repo, pats, opts)
+        m = scmutil.match(repo, pats, opts)
         m.bad = badfn
         for abs in repo[node].walk(m):
             if abs not in names:
                 names[abs] = m.rel(abs), m.exact(abs)
 
-        m = cmdutil.matchfiles(repo, names)
+        m = scmutil.matchfiles(repo, names)
         changes = repo.status(match=m)[:4]
         modified, added, removed, deleted = map(set, changes)
 
@@ -4531,7 +4531,7 @@
     if not show:
         show = ui.quiet and states[:4] or states[:5]
 
-    stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
+    stat = repo.status(node1, node2, scmutil.match(repo, pats, opts),
                        'ignored' in show, 'clean' in show, 'unknown' in show,
                        opts.get('subrepos'))
     changestates = zip(states, 'MAR!?IC', stat)
--- a/tests/autodiff.py	Fri May 13 14:48:48 2011 -0500
+++ b/tests/autodiff.py	Fri May 13 14:58:24 2011 -0500
@@ -1,7 +1,7 @@
 # Extension dedicated to test patch.diff() upgrade modes
 #
 #
-from mercurial import cmdutil, scmutil, patch, util
+from mercurial import scmutil, patch, util
 
 def autodiff(ui, repo, *pats, **opts):
     diffopts = patch.diffopts(ui, opts)
@@ -29,7 +29,7 @@
         raise util.Abort('--git must be yes, no or auto')
 
     node1, node2 = scmutil.revpair(repo, [])
-    m = cmdutil.match(repo, pats, opts)
+    m = scmutil.match(repo, pats, opts)
     it = patch.diff(repo, node1, node2, match=m, opts=diffopts,
                     losedatafn=losedatafn)
     for chunk in it: