# HG changeset patch # User Matt Mackall # Date 1308433971 18000 # Node ID 2d2604adfdd66384dac3e79b3d5343b983334afa # Parent 2d6f1b2c6a8239ac5d0e3720ab9f73bc381dccb6 context: add a match builder method This is groundwork for matching against filesets in contexts diff -r 2d6f1b2c6a82 -r 2d2604adfdd6 mercurial/context.py --- a/mercurial/context.py Fri Jun 17 18:24:54 2011 -0300 +++ b/mercurial/context.py Sat Jun 18 16:52:51 2011 -0500 @@ -8,6 +8,7 @@ from node import nullid, nullrev, short, hex from i18n import _ import ancestor, bdiff, error, util, scmutil, subrepo, patch, encoding +import match as matchmod import os, errno, stat propertycache = util.propertycache @@ -208,6 +209,11 @@ def sub(self, path): return subrepo.subrepo(self, path) + def match(self, pats=[], include=None, exclude=None, default='glob'): + r = self._repo + return matchmod.match(r.root, r.getcwd(), pats, + include, exclude, default, auditor=r.auditor) + def diff(self, ctx2=None, match=None, **opts): """Returns a diff generator for the given contexts and matcher""" if ctx2 is None: diff -r 2d6f1b2c6a82 -r 2d2604adfdd6 mercurial/scmutil.py --- a/mercurial/scmutil.py Fri Jun 17 18:24:54 2011 -0300 +++ b/mercurial/scmutil.py Sat Jun 18 16:52:51 2011 -0500 @@ -563,9 +563,8 @@ pats = [] if not globbed and default == 'relpath': pats = expandpats(pats or []) - m = matchmod.match(repo.root, repo.getcwd(), pats, - opts.get('include'), opts.get('exclude'), default, - auditor=repo.auditor) + m = repo[None].match(pats, opts.get('include'), opts.get('exclude'), + default) def badfn(f, msg): repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) m.bad = badfn