Show More
@@ -47,7 +47,8 b" def walk(repo, pats, opts, head = ''):" | |||
|
47 | 47 | cwd = repo.getcwd() |
|
48 | 48 | c = 0 |
|
49 | 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 | 52 | yield src, fn, fn[c:] |
|
52 | 53 | |
|
53 | 54 | revrangesep = ':' |
@@ -1007,7 +1008,8 b' def status(ui, repo, *pats, **opts):' | |||
|
1007 | 1008 | R = removed |
|
1008 | 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 | 1013 | (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u)) |
|
1012 | 1014 | |
|
1013 | 1015 | for f in c: |
@@ -66,7 +66,15 b" def globre(pat, head = '^', tail = '$'):" | |||
|
66 | 66 | res += re.escape(c) |
|
67 | 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 | 78 | def regex(name, tail): |
|
71 | 79 | '''convert a pattern into a regular expression''' |
|
72 | 80 | if name.startswith('re:'): |
@@ -77,6 +85,8 b' def matcher(cwd, pats, inc, exc, head = ' | |||
|
77 | 85 | return head + globre(name[5:], '', tail) |
|
78 | 86 | return head + globre(name, '', tail) |
|
79 | 87 | |
|
88 | cwdsep = cwd + os.sep | |
|
89 | ||
|
80 | 90 | def under(fn): |
|
81 | 91 | """check if fn is under our cwd""" |
|
82 | 92 | return not cwd or fn.startswith(cwdsep) |
@@ -86,16 +96,25 b' def matcher(cwd, pats, inc, exc, head = ' | |||
|
86 | 96 | if pats: |
|
87 | 97 | pat = '(?:%s)' % '|'.join([regex(p, tail) for p in pats]) |
|
88 | 98 | if cwd: |
|
89 |
pat = re.escape(cwd |
|
|
99 | pat = re.escape(cwdsep) + pat | |
|
90 | 100 | return re.compile(pat).match |
|
91 | 101 | |
|
92 | cwdsep = cwd + os.sep | |
|
93 | patmatch = matchfn(pats, '$') or (lambda fn: True) | |
|
102 | pats = filter(patlike, names) | |
|
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 | 110 | incmatch = matchfn(inc, '(?:/|$)') or under |
|
95 | 111 | excmatch = matchfn(exc, '(?:/|$)') or (lambda fn: False) |
|
96 | 112 | |
|
97 | return lambda fn: (incmatch(fn) and not excmatch(fn) and | |
|
98 |
(fn.endswith('/') or |
|
|
113 | return plain, lambda fn: (incmatch(fn) and not excmatch(fn) and | |
|
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 | 119 | def system(cmd, errprefix=None): |
|
101 | 120 | """execute a shell command that must succeed""" |
General Comments 0
You need to be logged in to leave comments.
Login now