match: make 'match.files()' return list object always stable
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 23 May 2012 00:25:29 +0900
branchstable
changeset 16789 c17ce7cd5090
parent 16772 30e46d7138de
child 16790 2a0efa1112ac
match: make 'match.files()' return list object always 'exact' match objects are sometimes created with a non-list 'pattern' argument: - using 'set' in queue.refresh():hgext/mq.py match = scmutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs)) - using 'dict' in revert():mercurial/cmdutil.py (names = {}) m = scmutil.matchfiles(repo, names) 'exact' match objects return specified 'pattern' to callers of 'match.files()' as it is, so it is a non-list object. but almost all implementations expect 'match.files()' to return a list object, so this may causes problems: e.g. exception for "+" with another list object. this patch ensures that '_files' of 'exact' match objects is a list object. for non 'exact' match objects, parsing specified 'pattern' already ensures that it it a list one.
mercurial/match.py
--- a/mercurial/match.py	Sat May 19 17:19:55 2012 +0200
+++ b/mercurial/match.py	Wed May 23 00:25:29 2012 +0900
@@ -62,7 +62,10 @@
             pats = _normalize(exclude, 'glob', root, cwd, auditor)
             self.excludepat, em = _buildmatch(ctx, pats, '(?:/|$)')
         if exact:
-            self._files = patterns
+            if isinstance(patterns, list):
+                self._files = patterns
+            else:
+                self._files = list(patterns)
             pm = self.exact
         elif patterns:
             pats = _normalize(patterns, default, root, cwd, auditor)