Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 14671:35c2cc322ba8
scmutil: switch match users to supplying contexts
The most appropriate context is not always clearly defined. The obvious cases:
For working directory commands, we use None
For commands (eg annotate) with single revs, we use that revision
The less obvious cases:
For commands (eg status, diff) with a pair of revs, we use the second revision
For commands that take a range (like log), we use None
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 18 Jun 2011 16:52:51 -0500 |
parents | 2e9f379de0ac |
children | b0566467c492 |
line wrap: on
line diff
--- a/mercurial/commands.py Sat Jun 18 16:52:51 2011 -0500 +++ b/mercurial/commands.py Sat Jun 18 16:52:51 2011 -0500 @@ -162,7 +162,7 @@ Returns 0 if all files are successfully added. """ - m = scmutil.match(repo, pats, opts) + m = scmutil.match(repo[None], 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 = scmutil.match(repo, pats, opts) + m = scmutil.match(ctx, pats, opts) m.bad = bad follow = not opts.get('no_follow') for abs in ctx.walk(m): @@ -342,7 +342,7 @@ prefix = os.path.basename(repo.root) + '-%h' prefix = cmdutil.makefilename(repo, prefix, node) - matchfn = scmutil.match(repo, [], opts) + matchfn = scmutil.match(ctx, [], opts) archival.archive(repo, dest, node, kind, not opts.get('no_decode'), matchfn, prefix, subrepos=opts.get('subrepos')) @@ -944,7 +944,7 @@ """ ctx = scmutil.revsingle(repo, opts.get('rev')) err = 1 - m = scmutil.match(repo, (file1,) + pats, opts) + m = scmutil.match(ctx, (file1,) + pats, opts) for abs in ctx.walk(m): fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(), pathname=abs) @@ -1091,7 +1091,7 @@ node = cmdutil.commit(ui, repo, commitfunc, pats, opts) if not node: - stat = repo.status(match=scmutil.match(repo, pats, opts)) + stat = repo.status(match=scmutil.match(repo[None], pats, opts)) if stat[3]: ui.status(_("nothing changed (%d missing files, see 'hg status')\n") % len(stat[3])) @@ -1610,7 +1610,7 @@ if ui.verbose: tree = fileset.parse(expr)[0] ui.note(tree, "\n") - matcher = lambda x: scmutil.match(repo, x, default='glob') + matcher = lambda x: scmutil.match(repo[None], x, default='glob') for f in fileset.getfileset(repo[None], matcher, expr): ui.write("%s\n" % f) @@ -1857,7 +1857,7 @@ """dump rename information""" ctx = scmutil.revsingle(repo, opts.get('rev')) - m = scmutil.match(repo, (file1,) + pats, opts) + m = scmutil.match(ctx, (file1,) + pats, opts) for abs in ctx.walk(m): fctx = ctx[abs] o = fctx.filelog().renamed(fctx.filenode()) @@ -2106,7 +2106,7 @@ @command('debugwalk', walkopts, _('[OPTION]... [FILE]...')) def debugwalk(ui, repo, *pats, **opts): """show how files match on given patterns""" - m = scmutil.match(repo, pats, opts) + m = scmutil.match(repo[None], pats, opts) items = list(repo.walk(m)) if not items: return @@ -2192,7 +2192,7 @@ node1, node2 = node2, node1 diffopts = patch.diffopts(ui, opts) - m = scmutil.match(repo, pats, opts) + m = scmutil.match(repo[node2], pats, opts) cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, listsubrepos=opts.get('subrepos')) @@ -2272,7 +2272,7 @@ if not pats: raise util.Abort(_('no files specified')) - m = scmutil.match(repo, pats, opts) + m = scmutil.match(repo[None], pats, opts) s = repo.status(match=m, clean=True) forget = sorted(s[0] + s[1] + s[3] + s[6]) errs = 0 @@ -2438,7 +2438,7 @@ skip = {} revfiles = {} - matchfn = scmutil.match(repo, pats, opts) + matchfn = scmutil.match(repo[None], pats, opts) found = False follow = opts.get('follow') @@ -3313,7 +3313,7 @@ rev = scmutil.revsingle(repo, opts.get('rev'), None).node() ret = 1 - m = scmutil.match(repo, pats, opts, default='relglob') + m = scmutil.match(repo[rev], 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: @@ -3382,7 +3382,7 @@ Returns 0 on success. """ - matchfn = scmutil.match(repo, pats, opts) + matchfn = scmutil.match(repo[None], pats, opts) limit = cmdutil.loglimit(opts) count = 0 @@ -3437,7 +3437,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 = scmutil.match(repo, fns, default='path') + revmatchfn = scmutil.match(repo[None], fns, default='path') else: revmatchfn = matchfn @@ -3650,7 +3650,7 @@ ctx = scmutil.revsingle(repo, opts.get('rev'), None) if file_: - m = scmutil.match(repo, (file_,), opts) + m = scmutil.match(ctx, (file_,), opts) if m.anypats() or len(m.files()) != 1: raise util.Abort(_('can only specify an explicit filename')) file_ = m.files()[0] @@ -3968,7 +3968,7 @@ if not pats and not after: raise util.Abort(_('no files specified')) - m = scmutil.match(repo, pats, opts) + m = scmutil.match(repo[None], pats, opts) s = repo.status(match=m, clean=True) modified, added, deleted, clean = s[0], s[1], s[3], s[6] @@ -4102,7 +4102,7 @@ 'use --all to remerge all files')) ms = mergemod.mergestate(repo) - m = scmutil.match(repo, pats, opts) + m = scmutil.match(repo[None], pats, opts) ret = 0 for f in ms: @@ -4203,7 +4203,7 @@ try: # walk dirstate. - m = scmutil.match(repo, pats, opts) + m = scmutil.match(repo[None], pats, opts) m.bad = lambda x, y: False for abs in repo.walk(m): names[abs] = m.rel(abs), m.exact(abs) @@ -4219,7 +4219,7 @@ return ui.warn("%s: %s\n" % (m.rel(path), msg)) - m = scmutil.match(repo, pats, opts) + m = scmutil.match(repo[node], pats, opts) m.bad = badfn for abs in repo[node].walk(m): if abs not in names: @@ -4654,7 +4654,7 @@ if not show: show = ui.quiet and states[:4] or states[:5] - stat = repo.status(node1, node2, scmutil.match(repo, pats, opts), + stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), 'ignored' in show, 'clean' in show, 'unknown' in show, opts.get('subrepos')) changestates = zip(states, 'MAR!?IC', stat)