Show More
@@ -0,0 +1,37 | |||
|
1 | import util | |
|
2 | ||
|
3 | class match(object): | |
|
4 | def __init__(self, root, cwd, patterns, include, exclude, default): | |
|
5 | self._patterns = patterns | |
|
6 | self._root = root | |
|
7 | self._cwd = cwd | |
|
8 | self._include = include | |
|
9 | self._exclude = exclude | |
|
10 | f, mf, ap = util.matcher(self._root, self._cwd, self._patterns, | |
|
11 | self._include, self._exclude, self.src(), | |
|
12 | default) | |
|
13 | self._files = f | |
|
14 | self._fmap = dict.fromkeys(f) | |
|
15 | self._matchfn = mf | |
|
16 | self._anypats = ap | |
|
17 | def src(self): | |
|
18 | return None | |
|
19 | def __call__(self, fn): | |
|
20 | return self._matchfn(fn) | |
|
21 | def __iter__(self): | |
|
22 | for f in self._files: | |
|
23 | yield f | |
|
24 | def bad(self, f, msg): | |
|
25 | return True | |
|
26 | def dir(self, f): | |
|
27 | pass | |
|
28 | def missing(self, f): | |
|
29 | pass | |
|
30 | def exact(self, f): | |
|
31 | return f in self._fmap | |
|
32 | def rel(self, f): | |
|
33 | return util.pathto(self._root, self._cwd, f) | |
|
34 | def files(self): | |
|
35 | return self._files | |
|
36 | def anypats(self): | |
|
37 | return self._anypats |
@@ -8,7 +8,7 | |||
|
8 | 8 | from node import hex, nullid, nullrev, short |
|
9 | 9 | from i18n import _ |
|
10 | 10 | import os, sys, bisect, stat |
|
11 | import mdiff, bdiff, util, templater, templatefilters, patch, errno | |
|
11 | import mdiff, bdiff, util, templater, templatefilters, patch, errno, match | |
|
12 | 12 | |
|
13 | 13 | revrangesep = ':' |
|
14 | 14 | |
@@ -224,21 +224,18 def make_file(repo, pat, node=None, | |||
|
224 | 224 | mode) |
|
225 | 225 | |
|
226 | 226 | def matchpats(repo, pats=[], opts={}, globbed=False, default='relpath'): |
|
227 | pats = pats or [] | |
|
228 | 227 | if not globbed and default == 'relpath': |
|
229 | 228 | pats = util.expand_glob(pats or []) |
|
230 |
|
|
|
231 |
|
|
|
229 | m = match.match(repo.root, repo.getcwd(), pats, opts.get('include'), | |
|
230 | opts.get('exclude'), default) | |
|
231 | return m.files(), m, m.anypats() | |
|
232 | 232 | |
|
233 | 233 | def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, |
|
234 | 234 | default='relpath'): |
|
235 |
|
|
|
236 | default=default) | |
|
237 | exact = dict.fromkeys(files) | |
|
238 | cwd = repo.getcwd() | |
|
239 | for src, fn in repo.walk(node=node, files=files, match=matchfn, | |
|
235 | dummy, m, dummy = matchpats(repo, pats, opts, globbed, default) | |
|
236 | for src, fn in repo.walk(node=node, files=m.files(), match=m, | |
|
240 | 237 | badmatch=badmatch): |
|
241 |
yield src, fn, |
|
|
238 | yield src, fn, m.rel(fn), m.exact(fn) | |
|
242 | 239 | |
|
243 | 240 | def findrenames(repo, added=None, removed=None, threshold=0.5): |
|
244 | 241 | '''find renamed files -- yields (before, after, score) tuples''' |
@@ -786,7 +786,7 class localrepository(repo.repository): | |||
|
786 | 786 | update_dirstate = True |
|
787 | 787 | |
|
788 | 788 | if (not force and p2 != nullid and |
|
789 |
(files or match |
|
|
789 | (match.files() or match.anypats())): | |
|
790 | 790 | raise util.Abort(_('cannot partially commit a merge ' |
|
791 | 791 | '(do not specify files or patterns)')) |
|
792 | 792 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now