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

login
register
mail settings
Submitter Tomasz Kleczek
Date Dec. 11, 2012, 6:38 p.m.
Message ID <06bb43645aaf0a45bdb2.1355251107@dev408.prn1.facebook.com>
Download mbox | patch
Permalink /patch/61/
State Superseded
Headers show

Comments

Tomasz Kleczek - Dec. 11, 2012, 6:38 p.m.
# 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.

Patch

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)