[PATCH 12 of 15] speedy: keep a list of patterns that are matched against in match

Tomasz Kleczek tkleczek at fb.com
Tue Dec 11 12:38:27 CST 2012


# HG changeset patch
# User Tomasz Kleczek <tkleczek at fb.com>
# Date 1355249665 28800
# Branch stable
# Node ID 06bb43645aaf0a45bdb213d52998ff6da47ba07f
# Parent  5527ac001fae8e214d1e78af0dfe34872fc27af0
speedy: keep a list of patterns that are matched against in match

Speedy extension does query optimizations dependent on the types of
patterns the match object encapsulates. To enable this a list of these
patterns must be kept inside match instance.

Currently on the match instance initialization the patterns are
used to create a match function and are forget after.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -62,12 +62,17 @@
         self._files = []
         self._anypats = bool(include or exclude)
         self._ctx = ctx
+        self._pats = []
+        self._includepats = []
+        self._excludepats = []
 
         if include:
             pats = _normalize(include, 'glob', root, cwd, auditor)
+            self._includepats = pats
             self.includepat, im = _buildmatch(ctx, pats, '(?:/|$)')
         if exclude:
             pats = _normalize(exclude, 'glob', root, cwd, auditor)
+            self._excludepats = pats
             self.excludepat, em = _buildmatch(ctx, pats, '(?:/|$)')
         if exact:
             if isinstance(patterns, list):
@@ -75,8 +80,10 @@
             else:
                 self._files = list(patterns)
             pm = self.exact
+            self._pats = [('path', fn) for fn in self._files]
         elif patterns:
             pats = _normalize(patterns, default, root, cwd, auditor)
+            self._pats = pats
             self._files = _roots(pats)
             self._anypats = self._anypats or _anypats(pats)
             self.patternspat, pm = _buildmatch(ctx, pats, '$')
@@ -311,6 +318,8 @@
     pats = []
     for kind, name in [_patsplit(p, default) for p in names]:
         if kind in ('glob', 'relpath'):
+            if kind == 'relpath':
+                kind = 'path'
             name = scmutil.canonpath(root, cwd, name, auditor)
         elif kind in ('relglob', 'path'):
             name = util.normpath(name)


More information about the Mercurial-devel mailing list