Show More
@@ -1149,13 +1149,14 def grep(ui, repo, pattern, *pats, **opt | |||
|
1149 | 1149 | |
|
1150 | 1150 | prev = {} |
|
1151 | 1151 | def display(fn, rev, states, prevstates): |
|
1152 | counts = {'-': 0, '+': 0} | |
|
1152 | found = False | |
|
1153 | 1153 | filerevmatches = {} |
|
1154 | if not opts['all']: | |
|
1155 | a, b, r = prevstates, states, rev | |
|
1154 | r = prev.get(fn, -1) | |
|
1155 | if opts['all']: | |
|
1156 | iter = difflinestates(states, prevstates) | |
|
1156 | 1157 | else: |
|
1157 | a, b, r = states, prevstates, prev.get(fn, -1) | |
|
1158 |
for change, l in |
|
|
1158 | iter = [('', l) for l in prevstates] | |
|
1159 | for change, l in iter: | |
|
1159 | 1160 | cols = [fn, str(r)] |
|
1160 | 1161 | if opts['line_number']: |
|
1161 | 1162 | cols.append(str(l.linenum)) |
@@ -1171,14 +1172,14 def grep(ui, repo, pattern, *pats, **opt | |||
|
1171 | 1172 | else: |
|
1172 | 1173 | cols.append(l.line) |
|
1173 | 1174 | ui.write(sep.join(cols), eol) |
|
1174 |
|
|
|
1175 |
return |
|
|
1175 | found = True | |
|
1176 | return found | |
|
1176 | 1177 | |
|
1177 | 1178 | fstate = {} |
|
1178 | 1179 | skip = {} |
|
1179 | 1180 | get = util.cachefunc(lambda r: repo.changectx(r).changeset()) |
|
1180 | 1181 | changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) |
|
1181 |
|
|
|
1182 | found = False | |
|
1182 | 1183 | follow = opts.get('follow') |
|
1183 | 1184 | for st, rev, fns in changeiter: |
|
1184 | 1185 | if st == 'window': |
@@ -1207,10 +1208,10 def grep(ui, repo, pattern, *pats, **opt | |||
|
1207 | 1208 | if copy: |
|
1208 | 1209 | skip[copy] = True |
|
1209 | 1210 | continue |
|
1210 |
if n |
|
|
1211 |
|
|
|
1212 |
|
|
|
1213 |
if |
|
|
1211 | if fn in prev or fstate[fn]: | |
|
1212 | r = display(fn, rev, m, fstate[fn]) | |
|
1213 | found = found or r | |
|
1214 | if r and not opts['all']: | |
|
1214 | 1215 | skip[fn] = True |
|
1215 | 1216 | if copy: |
|
1216 | 1217 | skip[copy] = True |
@@ -1225,8 +1226,8 def grep(ui, repo, pattern, *pats, **opt | |||
|
1225 | 1226 | if fn in skip: |
|
1226 | 1227 | continue |
|
1227 | 1228 | if fn not in copies.get(prev[fn], {}): |
|
1228 | display(fn, rev, {}, state) | |
|
1229 |
return ( |
|
|
1229 | found = display(fn, rev, {}, state) or found | |
|
1230 | return (not found and 1) or 0 | |
|
1230 | 1231 | |
|
1231 | 1232 | def heads(ui, repo, **opts): |
|
1232 | 1233 | """show current repository heads |
@@ -31,3 +31,22 hg grep -f 'import$' port2 | |||
|
31 | 31 | echo deport >> port2 |
|
32 | 32 | hg commit -m 5 -u eggs -d '6 0' |
|
33 | 33 | hg grep -f --all -nu port port2 |
|
34 | ||
|
35 | cd .. | |
|
36 | hg init t2 | |
|
37 | cd t2 | |
|
38 | hg grep foobar foo | |
|
39 | hg grep foobar | |
|
40 | echo blue >> color | |
|
41 | echo black >> color | |
|
42 | hg add color | |
|
43 | hg ci -m 0 -d '0 0' | |
|
44 | echo orange >> color | |
|
45 | hg ci -m 1 -d '0 0' | |
|
46 | echo black > color | |
|
47 | hg ci -m 2 -d '0 0' | |
|
48 | echo orange >> color | |
|
49 | echo blue >> color | |
|
50 | hg ci -m 3 -d '0 0' | |
|
51 | hg grep orange | |
|
52 | hg grep --all orange |
General Comments 0
You need to be logged in to leave comments.
Login now