Patchwork [1,of,8,match] match: make it more clear what _roots do and that it ends up in match()._files

login
register
mail settings
Submitter Mads Kiilerich
Date April 15, 2014, 12:40 a.m.
Message ID <c6c885cf1001ffa68053.1397522435@mk-desktop>
Download mbox | patch
Permalink /patch/4353/
State Accepted
Commit b02ab6486a788d6962f862a98f884c321ab573a0
Headers show

Comments

Mads Kiilerich - April 15, 2014, 12:40 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1380816081 -7200
#      Thu Oct 03 18:01:21 2013 +0200
# Node ID c6c885cf1001ffa680530e960a9a5db499a7a85a
# Parent  bd4cc41234760cb1fc9a822eada1c37e5852c2b7
match: make it more clear what _roots do and that it ends up in match()._files

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -59,7 +59,7 @@  class match(object):
 
         self._root = root
         self._cwd = cwd
-        self._files = []
+        self._files = [] # exact files and roots of patterns
         self._anypats = bool(include or exclude)
         self._ctx = ctx
         self._always = False
@@ -337,6 +337,15 @@  def _normalize(names, default, root, cwd
     return pats
 
 def _roots(patterns):
+    '''return roots and exact explicitly listed files from patterns
+
+    >>> _roots([('glob', 'g/*'), ('glob', 'g'), ('glob', 'g*')])
+    ['g', 'g', '.']
+    >>> _roots([('relpath', 'r'), ('path', 'p/p'), ('path', '')])
+    ['r', 'p/p', '.']
+    >>> _roots([('relglob', 'rg*'), ('re', 're/'), ('relre', 'rr')])
+    ['.', '.', '.']
+    '''
     r = []
     for kind, name in patterns:
         if kind == 'glob': # find the non-glob prefix