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 | from node import hex, nullid, nullrev, short |
|
8 | from node import hex, nullid, nullrev, short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import os, sys, bisect, stat |
|
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 | revrangesep = ':' |
|
13 | revrangesep = ':' | |
14 |
|
14 | |||
@@ -224,21 +224,18 def make_file(repo, pat, node=None, | |||||
224 | mode) |
|
224 | mode) | |
225 |
|
225 | |||
226 | def matchpats(repo, pats=[], opts={}, globbed=False, default='relpath'): |
|
226 | def matchpats(repo, pats=[], opts={}, globbed=False, default='relpath'): | |
227 | pats = pats or [] |
|
|||
228 | if not globbed and default == 'relpath': |
|
227 | if not globbed and default == 'relpath': | |
229 | pats = util.expand_glob(pats or []) |
|
228 | pats = util.expand_glob(pats or []) | |
230 |
|
|
229 | m = match.match(repo.root, repo.getcwd(), pats, opts.get('include'), | |
231 |
|
|
230 | opts.get('exclude'), default) | |
|
231 | return m.files(), m, m.anypats() | |||
232 |
|
232 | |||
233 | def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, |
|
233 | def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, | |
234 | default='relpath'): |
|
234 | default='relpath'): | |
235 |
|
|
235 | dummy, m, dummy = matchpats(repo, pats, opts, globbed, default) | |
236 | default=default) |
|
236 | for src, fn in repo.walk(node=node, files=m.files(), match=m, | |
237 | exact = dict.fromkeys(files) |
|
|||
238 | cwd = repo.getcwd() |
|
|||
239 | for src, fn in repo.walk(node=node, files=files, match=matchfn, |
|
|||
240 | badmatch=badmatch): |
|
237 | badmatch=badmatch): | |
241 |
yield src, fn, |
|
238 | yield src, fn, m.rel(fn), m.exact(fn) | |
242 |
|
239 | |||
243 | def findrenames(repo, added=None, removed=None, threshold=0.5): |
|
240 | def findrenames(repo, added=None, removed=None, threshold=0.5): | |
244 | '''find renamed files -- yields (before, after, score) tuples''' |
|
241 | '''find renamed files -- yields (before, after, score) tuples''' |
@@ -786,7 +786,7 class localrepository(repo.repository): | |||||
786 | update_dirstate = True |
|
786 | update_dirstate = True | |
787 |
|
787 | |||
788 | if (not force and p2 != nullid and |
|
788 | if (not force and p2 != nullid and | |
789 |
(files or match |
|
789 | (match.files() or match.anypats())): | |
790 | raise util.Abort(_('cannot partially commit a merge ' |
|
790 | raise util.Abort(_('cannot partially commit a merge ' | |
791 | '(do not specify files or patterns)')) |
|
791 | '(do not specify files or patterns)')) | |
792 | else: |
|
792 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now