##// END OF EJS Templates
scmutil: switch match users to supplying contexts...
Matt Mackall -
r14671:35c2cc32 default
parent child Browse files
Show More
@@ -31,11 +31,11 b' def timer(func, title=None):'
31
31
32 def perfwalk(ui, repo, *pats):
32 def perfwalk(ui, repo, *pats):
33 try:
33 try:
34 m = scmutil.match(repo, pats, {})
34 m = scmutil.match(repo[None], pats, {})
35 timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
35 timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
36 except:
36 except:
37 try:
37 try:
38 m = scmutil.match(repo, pats, {})
38 m = scmutil.match(repo[None], pats, {})
39 timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)]))
39 timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)]))
40 except:
40 except:
41 timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
41 timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
@@ -54,7 +54,7 b' def countrate(ui, repo, amap, *pats, **o'
54 if opts.get('date'):
54 if opts.get('date'):
55 df = util.matchdate(opts['date'])
55 df = util.matchdate(opts['date'])
56
56
57 m = scmutil.match(repo, pats, opts)
57 m = scmutil.match(repo[None], pats, opts)
58 def prep(ctx, fns):
58 def prep(ctx, fns):
59 rev = ctx.rev()
59 rev = ctx.rev()
60 if df and not df(ctx.date()[0]): # doesn't match date format
60 if df and not df(ctx.date()[0]): # doesn't match date format
@@ -137,7 +137,7 b' def dodiff(ui, repo, diffcmd, diffopts, '
137 if node1b == nullid:
137 if node1b == nullid:
138 do3way = False
138 do3way = False
139
139
140 matcher = scmutil.match(repo, pats, opts)
140 matcher = scmutil.match(repo[node2], pats, opts)
141 mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher)[:3])
141 mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher)[:3])
142 if do3way:
142 if do3way:
143 mod_b, add_b, rem_b = map(set, repo.status(node1b, node2, matcher)[:3])
143 mod_b, add_b, rem_b = map(set, repo.status(node1b, node2, matcher)[:3])
@@ -45,7 +45,7 b' def difftree(ui, repo, node1=None, node2'
45 assert node2 is not None
45 assert node2 is not None
46 mmap = repo[node1].manifest()
46 mmap = repo[node1].manifest()
47 mmap2 = repo[node2].manifest()
47 mmap2 = repo[node2].manifest()
48 m = scmutil.match(repo, files)
48 m = scmutil.match(repo[node1], files)
49 modified, added, removed = repo.status(node1, node2, m)[:3]
49 modified, added, removed = repo.status(node1, node2, m)[:3]
50 empty = short(nullid)
50 empty = short(nullid)
51
51
@@ -81,7 +81,7 b' def difftree(ui, repo, node1=None, node2'
81 if opts['patch']:
81 if opts['patch']:
82 if opts['pretty']:
82 if opts['pretty']:
83 catcommit(ui, repo, node2, "")
83 catcommit(ui, repo, node2, "")
84 m = scmutil.match(repo, files)
84 m = scmutil.match(repo[node1], files)
85 chunks = patch.diff(repo, node1, node2, match=m,
85 chunks = patch.diff(repo, node1, node2, match=m,
86 opts=patch.diffopts(ui, {'git': True}))
86 opts=patch.diffopts(ui, {'git': True}))
87 for chunk in chunks:
87 for chunk in chunks:
@@ -326,7 +326,7 b' def _status(ui, repo, kwt, *pats, **opts'
326 '''Bails out if [keyword] configuration is not active.
326 '''Bails out if [keyword] configuration is not active.
327 Returns status of working directory.'''
327 Returns status of working directory.'''
328 if kwt:
328 if kwt:
329 return repo.status(match=scmutil.match(repo, pats, opts), clean=True,
329 return repo.status(match=scmutil.match(repo[None], pats, opts), clean=True,
330 unknown=opts.get('unknown') or opts.get('all'))
330 unknown=opts.get('unknown') or opts.get('all'))
331 if ui.configitems('keyword'):
331 if ui.configitems('keyword'):
332 raise util.Abort(_('[keyword] patterns cannot match'))
332 raise util.Abort(_('[keyword] patterns cannot match'))
@@ -519,7 +519,7 b' class queue(object):'
519 def printdiff(self, repo, diffopts, node1, node2=None, files=None,
519 def printdiff(self, repo, diffopts, node1, node2=None, files=None,
520 fp=None, changes=None, opts={}):
520 fp=None, changes=None, opts={}):
521 stat = opts.get('stat')
521 stat = opts.get('stat')
522 m = scmutil.match(repo, files, opts)
522 m = scmutil.match(repo[node1], files, opts)
523 cmdutil.diffordiffstat(self.ui, repo, diffopts, node1, node2, m,
523 cmdutil.diffordiffstat(self.ui, repo, diffopts, node1, node2, m,
524 changes, stat, fp)
524 changes, stat, fp)
525
525
@@ -899,7 +899,7 b' class queue(object):'
899 if opts.get('include') or opts.get('exclude') or pats:
899 if opts.get('include') or opts.get('exclude') or pats:
900 if inclsubs:
900 if inclsubs:
901 pats = list(pats or []) + inclsubs
901 pats = list(pats or []) + inclsubs
902 match = scmutil.match(repo, pats, opts)
902 match = scmutil.match(repo[None], pats, opts)
903 # detect missing files in pats
903 # detect missing files in pats
904 def badfn(f, msg):
904 def badfn(f, msg):
905 if f != '.hgsubstate': # .hgsubstate is auto-created
905 if f != '.hgsubstate': # .hgsubstate is auto-created
@@ -1380,7 +1380,7 b' class queue(object):'
1380 changes = repo.changelog.read(top)
1380 changes = repo.changelog.read(top)
1381 man = repo.manifest.read(changes[0])
1381 man = repo.manifest.read(changes[0])
1382 aaa = aa[:]
1382 aaa = aa[:]
1383 matchfn = scmutil.match(repo, pats, opts)
1383 matchfn = scmutil.match(repo[None], pats, opts)
1384 # in short mode, we only diff the files included in the
1384 # in short mode, we only diff the files included in the
1385 # patch already plus specified files
1385 # patch already plus specified files
1386 if opts.get('short'):
1386 if opts.get('short'):
@@ -1388,7 +1388,7 b' class queue(object):'
1388 # files plus specified files - unfiltered
1388 # files plus specified files - unfiltered
1389 match = scmutil.matchfiles(repo, mm + aa + dd + matchfn.files())
1389 match = scmutil.matchfiles(repo, mm + aa + dd + matchfn.files())
1390 # filter with inc/exl options
1390 # filter with inc/exl options
1391 matchfn = scmutil.match(repo, opts=opts)
1391 matchfn = scmutil.match(repo[None], opts=opts)
1392 else:
1392 else:
1393 match = scmutil.matchall(repo)
1393 match = scmutil.matchall(repo)
1394 m, a, r, d = repo.status(match=match)[:4]
1394 m, a, r, d = repo.status(match=match)[:4]
@@ -96,7 +96,7 b' def purge(ui, repo, *dirs, **opts):'
96 os.remove(path)
96 os.remove(path)
97
97
98 directories = []
98 directories = []
99 match = scmutil.match(repo, dirs, opts)
99 match = scmutil.match(repo[None], dirs, opts)
100 match.dir = directories.append
100 match.dir = directories.append
101 status = repo.status(match=match, ignored=opts['all'], unknown=True)
101 status = repo.status(match=match, ignored=opts['all'], unknown=True)
102
102
@@ -234,7 +234,7 b' def copy(ui, repo, pats, opts, rename=Fa'
234 def walkpat(pat):
234 def walkpat(pat):
235 srcs = []
235 srcs = []
236 badstates = after and '?' or '?r'
236 badstates = after and '?' or '?r'
237 m = scmutil.match(repo, [pat], opts, globbed=True)
237 m = scmutil.match(repo[None], [pat], opts, globbed=True)
238 for abs in repo.walk(m):
238 for abs in repo.walk(m):
239 state = repo.dirstate[abs]
239 state = repo.dirstate[abs]
240 rel = m.rel(abs)
240 rel = m.rel(abs)
@@ -1185,7 +1185,8 b' def commit(ui, repo, commitfunc, pats, o'
1185 if opts.get('addremove'):
1185 if opts.get('addremove'):
1186 scmutil.addremove(repo, pats, opts)
1186 scmutil.addremove(repo, pats, opts)
1187
1187
1188 return commitfunc(ui, repo, message, scmutil.match(repo, pats, opts), opts)
1188 return commitfunc(ui, repo, message,
1189 scmutil.match(repo[None], pats, opts), opts)
1189
1190
1190 def commiteditor(repo, ctx, subs):
1191 def commiteditor(repo, ctx, subs):
1191 if ctx.description():
1192 if ctx.description():
@@ -162,7 +162,7 b' def add(ui, repo, *pats, **opts):'
162 Returns 0 if all files are successfully added.
162 Returns 0 if all files are successfully added.
163 """
163 """
164
164
165 m = scmutil.match(repo, pats, opts)
165 m = scmutil.match(repo[None], pats, opts)
166 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
166 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
167 opts.get('subrepos'), prefix="")
167 opts.get('subrepos'), prefix="")
168 return rejected and 1 or 0
168 return rejected and 1 or 0
@@ -262,7 +262,7 b' def annotate(ui, repo, *pats, **opts):'
262 raise util.Abort("%s: %s" % (x, y))
262 raise util.Abort("%s: %s" % (x, y))
263
263
264 ctx = scmutil.revsingle(repo, opts.get('rev'))
264 ctx = scmutil.revsingle(repo, opts.get('rev'))
265 m = scmutil.match(repo, pats, opts)
265 m = scmutil.match(ctx, pats, opts)
266 m.bad = bad
266 m.bad = bad
267 follow = not opts.get('no_follow')
267 follow = not opts.get('no_follow')
268 for abs in ctx.walk(m):
268 for abs in ctx.walk(m):
@@ -342,7 +342,7 b' def archive(ui, repo, dest, **opts):'
342 prefix = os.path.basename(repo.root) + '-%h'
342 prefix = os.path.basename(repo.root) + '-%h'
343
343
344 prefix = cmdutil.makefilename(repo, prefix, node)
344 prefix = cmdutil.makefilename(repo, prefix, node)
345 matchfn = scmutil.match(repo, [], opts)
345 matchfn = scmutil.match(ctx, [], opts)
346 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
346 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
347 matchfn, prefix, subrepos=opts.get('subrepos'))
347 matchfn, prefix, subrepos=opts.get('subrepos'))
348
348
@@ -944,7 +944,7 b' def cat(ui, repo, file1, *pats, **opts):'
944 """
944 """
945 ctx = scmutil.revsingle(repo, opts.get('rev'))
945 ctx = scmutil.revsingle(repo, opts.get('rev'))
946 err = 1
946 err = 1
947 m = scmutil.match(repo, (file1,) + pats, opts)
947 m = scmutil.match(ctx, (file1,) + pats, opts)
948 for abs in ctx.walk(m):
948 for abs in ctx.walk(m):
949 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
949 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
950 pathname=abs)
950 pathname=abs)
@@ -1091,7 +1091,7 b' def commit(ui, repo, *pats, **opts):'
1091
1091
1092 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1092 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1093 if not node:
1093 if not node:
1094 stat = repo.status(match=scmutil.match(repo, pats, opts))
1094 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1095 if stat[3]:
1095 if stat[3]:
1096 ui.status(_("nothing changed (%d missing files, see 'hg status')\n")
1096 ui.status(_("nothing changed (%d missing files, see 'hg status')\n")
1097 % len(stat[3]))
1097 % len(stat[3]))
@@ -1610,7 +1610,7 b' def debugfileset(ui, repo, expr):'
1610 if ui.verbose:
1610 if ui.verbose:
1611 tree = fileset.parse(expr)[0]
1611 tree = fileset.parse(expr)[0]
1612 ui.note(tree, "\n")
1612 ui.note(tree, "\n")
1613 matcher = lambda x: scmutil.match(repo, x, default='glob')
1613 matcher = lambda x: scmutil.match(repo[None], x, default='glob')
1614
1614
1615 for f in fileset.getfileset(repo[None], matcher, expr):
1615 for f in fileset.getfileset(repo[None], matcher, expr):
1616 ui.write("%s\n" % f)
1616 ui.write("%s\n" % f)
@@ -1857,7 +1857,7 b' def debugrename(ui, repo, file1, *pats, '
1857 """dump rename information"""
1857 """dump rename information"""
1858
1858
1859 ctx = scmutil.revsingle(repo, opts.get('rev'))
1859 ctx = scmutil.revsingle(repo, opts.get('rev'))
1860 m = scmutil.match(repo, (file1,) + pats, opts)
1860 m = scmutil.match(ctx, (file1,) + pats, opts)
1861 for abs in ctx.walk(m):
1861 for abs in ctx.walk(m):
1862 fctx = ctx[abs]
1862 fctx = ctx[abs]
1863 o = fctx.filelog().renamed(fctx.filenode())
1863 o = fctx.filelog().renamed(fctx.filenode())
@@ -2106,7 +2106,7 b' def debugsub(ui, repo, rev=None):'
2106 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'))
2106 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'))
2107 def debugwalk(ui, repo, *pats, **opts):
2107 def debugwalk(ui, repo, *pats, **opts):
2108 """show how files match on given patterns"""
2108 """show how files match on given patterns"""
2109 m = scmutil.match(repo, pats, opts)
2109 m = scmutil.match(repo[None], pats, opts)
2110 items = list(repo.walk(m))
2110 items = list(repo.walk(m))
2111 if not items:
2111 if not items:
2112 return
2112 return
@@ -2192,7 +2192,7 b' def diff(ui, repo, *pats, **opts):'
2192 node1, node2 = node2, node1
2192 node1, node2 = node2, node1
2193
2193
2194 diffopts = patch.diffopts(ui, opts)
2194 diffopts = patch.diffopts(ui, opts)
2195 m = scmutil.match(repo, pats, opts)
2195 m = scmutil.match(repo[node2], pats, opts)
2196 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
2196 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
2197 listsubrepos=opts.get('subrepos'))
2197 listsubrepos=opts.get('subrepos'))
2198
2198
@@ -2272,7 +2272,7 b' def forget(ui, repo, *pats, **opts):'
2272 if not pats:
2272 if not pats:
2273 raise util.Abort(_('no files specified'))
2273 raise util.Abort(_('no files specified'))
2274
2274
2275 m = scmutil.match(repo, pats, opts)
2275 m = scmutil.match(repo[None], pats, opts)
2276 s = repo.status(match=m, clean=True)
2276 s = repo.status(match=m, clean=True)
2277 forget = sorted(s[0] + s[1] + s[3] + s[6])
2277 forget = sorted(s[0] + s[1] + s[3] + s[6])
2278 errs = 0
2278 errs = 0
@@ -2438,7 +2438,7 b' def grep(ui, repo, pattern, *pats, **opt'
2438
2438
2439 skip = {}
2439 skip = {}
2440 revfiles = {}
2440 revfiles = {}
2441 matchfn = scmutil.match(repo, pats, opts)
2441 matchfn = scmutil.match(repo[None], pats, opts)
2442 found = False
2442 found = False
2443 follow = opts.get('follow')
2443 follow = opts.get('follow')
2444
2444
@@ -3313,7 +3313,7 b' def locate(ui, repo, *pats, **opts):'
3313 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3313 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3314
3314
3315 ret = 1
3315 ret = 1
3316 m = scmutil.match(repo, pats, opts, default='relglob')
3316 m = scmutil.match(repo[rev], pats, opts, default='relglob')
3317 m.bad = lambda x, y: False
3317 m.bad = lambda x, y: False
3318 for abs in repo[rev].walk(m):
3318 for abs in repo[rev].walk(m):
3319 if not rev and abs not in repo.dirstate:
3319 if not rev and abs not in repo.dirstate:
@@ -3382,7 +3382,7 b' def log(ui, repo, *pats, **opts):'
3382 Returns 0 on success.
3382 Returns 0 on success.
3383 """
3383 """
3384
3384
3385 matchfn = scmutil.match(repo, pats, opts)
3385 matchfn = scmutil.match(repo[None], pats, opts)
3386 limit = cmdutil.loglimit(opts)
3386 limit = cmdutil.loglimit(opts)
3387 count = 0
3387 count = 0
3388
3388
@@ -3437,7 +3437,7 b' def log(ui, repo, *pats, **opts):'
3437 if opts.get('patch') or opts.get('stat'):
3437 if opts.get('patch') or opts.get('stat'):
3438 if opts.get('follow') or opts.get('follow_first'):
3438 if opts.get('follow') or opts.get('follow_first'):
3439 # note: this might be wrong when following through merges
3439 # note: this might be wrong when following through merges
3440 revmatchfn = scmutil.match(repo, fns, default='path')
3440 revmatchfn = scmutil.match(repo[None], fns, default='path')
3441 else:
3441 else:
3442 revmatchfn = matchfn
3442 revmatchfn = matchfn
3443
3443
@@ -3650,7 +3650,7 b' def parents(ui, repo, file_=None, **opts'
3650 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3650 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3651
3651
3652 if file_:
3652 if file_:
3653 m = scmutil.match(repo, (file_,), opts)
3653 m = scmutil.match(ctx, (file_,), opts)
3654 if m.anypats() or len(m.files()) != 1:
3654 if m.anypats() or len(m.files()) != 1:
3655 raise util.Abort(_('can only specify an explicit filename'))
3655 raise util.Abort(_('can only specify an explicit filename'))
3656 file_ = m.files()[0]
3656 file_ = m.files()[0]
@@ -3968,7 +3968,7 b' def remove(ui, repo, *pats, **opts):'
3968 if not pats and not after:
3968 if not pats and not after:
3969 raise util.Abort(_('no files specified'))
3969 raise util.Abort(_('no files specified'))
3970
3970
3971 m = scmutil.match(repo, pats, opts)
3971 m = scmutil.match(repo[None], pats, opts)
3972 s = repo.status(match=m, clean=True)
3972 s = repo.status(match=m, clean=True)
3973 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
3973 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
3974
3974
@@ -4102,7 +4102,7 b' def resolve(ui, repo, *pats, **opts):'
4102 'use --all to remerge all files'))
4102 'use --all to remerge all files'))
4103
4103
4104 ms = mergemod.mergestate(repo)
4104 ms = mergemod.mergestate(repo)
4105 m = scmutil.match(repo, pats, opts)
4105 m = scmutil.match(repo[None], pats, opts)
4106 ret = 0
4106 ret = 0
4107
4107
4108 for f in ms:
4108 for f in ms:
@@ -4203,7 +4203,7 b' def revert(ui, repo, *pats, **opts):'
4203 try:
4203 try:
4204 # walk dirstate.
4204 # walk dirstate.
4205
4205
4206 m = scmutil.match(repo, pats, opts)
4206 m = scmutil.match(repo[None], pats, opts)
4207 m.bad = lambda x, y: False
4207 m.bad = lambda x, y: False
4208 for abs in repo.walk(m):
4208 for abs in repo.walk(m):
4209 names[abs] = m.rel(abs), m.exact(abs)
4209 names[abs] = m.rel(abs), m.exact(abs)
@@ -4219,7 +4219,7 b' def revert(ui, repo, *pats, **opts):'
4219 return
4219 return
4220 ui.warn("%s: %s\n" % (m.rel(path), msg))
4220 ui.warn("%s: %s\n" % (m.rel(path), msg))
4221
4221
4222 m = scmutil.match(repo, pats, opts)
4222 m = scmutil.match(repo[node], pats, opts)
4223 m.bad = badfn
4223 m.bad = badfn
4224 for abs in repo[node].walk(m):
4224 for abs in repo[node].walk(m):
4225 if abs not in names:
4225 if abs not in names:
@@ -4654,7 +4654,7 b' def status(ui, repo, *pats, **opts):'
4654 if not show:
4654 if not show:
4655 show = ui.quiet and states[:4] or states[:5]
4655 show = ui.quiet and states[:4] or states[:5]
4656
4656
4657 stat = repo.status(node1, node2, scmutil.match(repo, pats, opts),
4657 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
4658 'ignored' in show, 'clean' in show, 'unknown' in show,
4658 'ignored' in show, 'clean' in show, 'unknown' in show,
4659 opts.get('subrepos'))
4659 opts.get('subrepos'))
4660 changestates = zip(states, 'MAR!?IC', stat)
4660 changestates = zip(states, 'MAR!?IC', stat)
@@ -573,7 +573,7 b' def match(ctxorrepo, pats=[], opts={}, g'
573 m = ctx.match(pats, opts.get('include'), opts.get('exclude'),
573 m = ctx.match(pats, opts.get('include'), opts.get('exclude'),
574 default)
574 default)
575 def badfn(f, msg):
575 def badfn(f, msg):
576 repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
576 ctx._repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
577 m.bad = badfn
577 m.bad = badfn
578 return m
578 return m
579
579
@@ -591,7 +591,7 b' def addremove(repo, pats=[], opts={}, dr'
591 # we'd use status here, except handling of symlinks and ignore is tricky
591 # we'd use status here, except handling of symlinks and ignore is tricky
592 added, unknown, deleted, removed = [], [], [], []
592 added, unknown, deleted, removed = [], [], [], []
593 audit_path = pathauditor(repo.root)
593 audit_path = pathauditor(repo.root)
594 m = match(repo, pats, opts)
594 m = match(repo[None], pats, opts)
595 for abs in repo.walk(m):
595 for abs in repo.walk(m):
596 target = repo.wjoin(abs)
596 target = repo.wjoin(abs)
597 good = True
597 good = True
@@ -29,7 +29,7 b' def autodiff(ui, repo, *pats, **opts):'
29 raise util.Abort('--git must be yes, no or auto')
29 raise util.Abort('--git must be yes, no or auto')
30
30
31 node1, node2 = scmutil.revpair(repo, [])
31 node1, node2 = scmutil.revpair(repo, [])
32 m = scmutil.match(repo, pats, opts)
32 m = scmutil.match(repo[node2], pats, opts)
33 it = patch.diff(repo, node1, node2, match=m, opts=diffopts,
33 it = patch.diff(repo, node1, node2, match=m, opts=diffopts,
34 losedatafn=losedatafn)
34 losedatafn=losedatafn)
35 for chunk in it:
35 for chunk in it:
General Comments 0
You need to be logged in to leave comments. Login now