Show More
@@ -47,7 +47,8 b" def walk(repo, pats, opts, head = ''):" | |||||
47 | cwd = repo.getcwd() |
|
47 | cwd = repo.getcwd() | |
48 | c = 0 |
|
48 | c = 0 | |
49 | if cwd: c = len(cwd) + 1 |
|
49 | if cwd: c = len(cwd) + 1 | |
50 |
f |
|
50 | files, matchfn = matchpats(cwd, pats, opts, head) | |
|
51 | for src, fn in repo.walk(files = files, match = matchfn): | |||
51 | yield src, fn, fn[c:] |
|
52 | yield src, fn, fn[c:] | |
52 |
|
53 | |||
53 | revrangesep = ':' |
|
54 | revrangesep = ':' | |
@@ -1007,7 +1008,8 b' def status(ui, repo, *pats, **opts):' | |||||
1007 | R = removed |
|
1008 | R = removed | |
1008 | ? = not tracked''' |
|
1009 | ? = not tracked''' | |
1009 |
|
1010 | |||
1010 |
|
|
1011 | files, matchfn = matchpats(repo.getcwd(), pats, opts) | |
|
1012 | (c, a, d, u) = repo.changes(files = files, match = matchfn) | |||
1011 | (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u)) |
|
1013 | (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u)) | |
1012 |
|
1014 | |||
1013 | for f in c: |
|
1015 | for f in c: |
@@ -66,7 +66,15 b" def globre(pat, head = '^', tail = '$'):" | |||||
66 | res += re.escape(c) |
|
66 | res += re.escape(c) | |
67 | return head + res + tail |
|
67 | return head + res + tail | |
68 |
|
68 | |||
69 | def matcher(cwd, pats, inc, exc, head = ''): |
|
69 | _globchars = {'[': 1, '{': 1, '*': 1, '?': 1} | |
|
70 | ||||
|
71 | def matcher(cwd, names, inc, exc, head = ''): | |||
|
72 | def patlike(name): | |||
|
73 | for prefix in 're:', 'glob:', 'path:': | |||
|
74 | if name.startswith(prefix): return True | |||
|
75 | for c in name: | |||
|
76 | if c in _globchars: return True | |||
|
77 | ||||
70 | def regex(name, tail): |
|
78 | def regex(name, tail): | |
71 | '''convert a pattern into a regular expression''' |
|
79 | '''convert a pattern into a regular expression''' | |
72 | if name.startswith('re:'): |
|
80 | if name.startswith('re:'): | |
@@ -77,6 +85,8 b' def matcher(cwd, pats, inc, exc, head = ' | |||||
77 | return head + globre(name[5:], '', tail) |
|
85 | return head + globre(name[5:], '', tail) | |
78 | return head + globre(name, '', tail) |
|
86 | return head + globre(name, '', tail) | |
79 |
|
87 | |||
|
88 | cwdsep = cwd + os.sep | |||
|
89 | ||||
80 | def under(fn): |
|
90 | def under(fn): | |
81 | """check if fn is under our cwd""" |
|
91 | """check if fn is under our cwd""" | |
82 | return not cwd or fn.startswith(cwdsep) |
|
92 | return not cwd or fn.startswith(cwdsep) | |
@@ -86,16 +96,25 b' def matcher(cwd, pats, inc, exc, head = ' | |||||
86 | if pats: |
|
96 | if pats: | |
87 | pat = '(?:%s)' % '|'.join([regex(p, tail) for p in pats]) |
|
97 | pat = '(?:%s)' % '|'.join([regex(p, tail) for p in pats]) | |
88 | if cwd: |
|
98 | if cwd: | |
89 |
pat = re.escape(cwd |
|
99 | pat = re.escape(cwdsep) + pat | |
90 | return re.compile(pat).match |
|
100 | return re.compile(pat).match | |
91 |
|
101 | |||
92 | cwdsep = cwd + os.sep |
|
102 | pats = filter(patlike, names) | |
93 | patmatch = matchfn(pats, '$') or (lambda fn: True) |
|
103 | files = [n for n in names if not patlike(n)] | |
|
104 | if pats: plain = [] | |||
|
105 | elif cwd: plain = [cwdsep + f for f in files] | |||
|
106 | else: plain = files | |||
|
107 | ||||
|
108 | patmatch = matchfn(pats, '$') | |||
|
109 | filematch = matchfn(files, '(?:/|$)') | |||
94 | incmatch = matchfn(inc, '(?:/|$)') or under |
|
110 | incmatch = matchfn(inc, '(?:/|$)') or under | |
95 | excmatch = matchfn(exc, '(?:/|$)') or (lambda fn: False) |
|
111 | excmatch = matchfn(exc, '(?:/|$)') or (lambda fn: False) | |
96 |
|
112 | |||
97 | return lambda fn: (incmatch(fn) and not excmatch(fn) and |
|
113 | return plain, lambda fn: (incmatch(fn) and not excmatch(fn) and | |
98 |
(fn.endswith('/') or |
|
114 | (fn.endswith('/') or | |
|
115 | (not pats and not files) or | |||
|
116 | (pats and patmatch(fn)) or | |||
|
117 | (files and filematch(fn)))) | |||
99 |
|
118 | |||
100 | def system(cmd, errprefix=None): |
|
119 | def system(cmd, errprefix=None): | |
101 | """execute a shell command that must succeed""" |
|
120 | """execute a shell command that must succeed""" |
General Comments 0
You need to be logged in to leave comments.
Login now