diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -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 timer(func, title=None): 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, {})))) diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -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 maketemplater(ui, repo, tmpl): 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 @@ def countrate(ui, repo, amap, *pats, **o 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 diff --git a/hgext/extdiff.py b/hgext/extdiff.py --- a/hgext/extdiff.py +++ b/hgext/extdiff.py @@ -62,7 +62,7 @@ pretty fast (at least faster than having 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 @@ def dodiff(ui, repo, diffcmd, diffopts, 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]) diff --git a/hgext/hgk.py b/hgext/hgk.py --- a/hgext/hgk.py +++ b/hgext/hgk.py @@ -35,7 +35,7 @@ vdiff on hovered and selected revisions. ''' 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 @@ def difftree(ui, repo, node1=None, node2 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 @@ def difftree(ui, repo, node1=None, node2 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: diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -326,7 +326,7 @@ def _status(ui, repo, kwt, *pats, **opts '''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')) diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -46,7 +46,7 @@ from mercurial.i18n import _ 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 @@ class queue(object): 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 @@ class queue(object): 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 @@ class queue(object): 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 @@ class queue(object): 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 @@ class queue(object): 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 @@ class queue(object): 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: diff --git a/hgext/purge.py b/hgext/purge.py --- a/hgext/purge.py +++ b/hgext/purge.py @@ -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 @@ def purge(ui, repo, *dirs, **opts): 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) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -12,10 +12,6 @@ import util, scmutil, templater, patch, 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 copy(ui, repo, pats, opts, rename=Fa 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 @@ def show_changeset(ui, repo, opts, buffe # 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 @@ def finddate(ui, repo, date): """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 @@ def commit(ui, repo, commitfunc, pats, o 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(): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -161,7 +161,7 @@ def add(ui, repo, *pats, **opts): 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 @@ def annotate(ui, repo, *pats, **opts): 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 @@ def archive(ui, repo, dest, **opts): 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 @@ def cat(ui, repo, file1, *pats, **opts): """ 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 @@ def commit(ui, repo, *pats, **opts): 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 @@ def debugrename(ui, repo, file1, *pats, """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 @@ def debugsub(ui, repo, rev=None): @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 @@ def diff(ui, repo, *pats, **opts): 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 @@ def forget(ui, repo, *pats, **opts): 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 @@ def grep(ui, repo, pattern, *pats, **opt skip = {} revfiles = {} - matchfn = cmdutil.match(repo, pats, opts) + matchfn = scmutil.match(repo, pats, opts) found = False follow = opts.get('follow') @@ -3100,7 +3100,7 @@ def import_(ui, repo, patch1, *patches, 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 @@ def locate(ui, repo, *pats, **opts): 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 @@ def log(ui, repo, *pats, **opts): 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 @@ def log(ui, repo, *pats, **opts): 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 @@ def parents(ui, repo, file_=None, **opts 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 @@ def remove(ui, repo, *pats, **opts): 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 @@ def resolve(ui, repo, *pats, **opts): '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 @@ def revert(ui, repo, *pats, **opts): 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 @@ def revert(ui, repo, *pats, **opts): 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 @@ def status(ui, repo, *pats, **opts): 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) diff --git a/tests/autodiff.py b/tests/autodiff.py --- a/tests/autodiff.py +++ b/tests/autodiff.py @@ -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 @@ def autodiff(ui, repo, *pats, **opts): 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: