comparison mercurial/commands.py @ 3950:3d3007064a17

grep: incrementing is always False during 'iter'
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Fri, 22 Dec 2006 22:16:05 +0100
parents 7997c0e01bfc
children cb66641cdee3
comparison
equal deleted inserted replaced
3946:be5d099e7a62 3950:3d3007064a17
1149 1149
1150 prev = {} 1150 prev = {}
1151 def display(fn, rev, states, prevstates): 1151 def display(fn, rev, states, prevstates):
1152 counts = {'-': 0, '+': 0} 1152 counts = {'-': 0, '+': 0}
1153 filerevmatches = {} 1153 filerevmatches = {}
1154 if incrementing or not opts['all']: 1154 if not opts['all']:
1155 a, b, r = prevstates, states, rev 1155 a, b, r = prevstates, states, rev
1156 else: 1156 else:
1157 a, b, r = states, prevstates, prev.get(fn, -1) 1157 a, b, r = states, prevstates, prev.get(fn, -1)
1158 for change, l in difflinestates(a, b): 1158 for change, l in difflinestates(a, b):
1159 cols = [fn, str(r)] 1159 cols = [fn, str(r)]
1177 fstate = {} 1177 fstate = {}
1178 skip = {} 1178 skip = {}
1179 get = util.cachefunc(lambda r: repo.changectx(r).changeset()) 1179 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
1180 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) 1180 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1181 count = 0 1181 count = 0
1182 incrementing = False
1183 follow = opts.get('follow') 1182 follow = opts.get('follow')
1184 for st, rev, fns in changeiter: 1183 for st, rev, fns in changeiter:
1185 if st == 'window': 1184 if st == 'window':
1186 incrementing = rev
1187 matches.clear() 1185 matches.clear()
1188 elif st == 'add': 1186 elif st == 'add':
1189 mf = repo.changectx(rev).manifest() 1187 mf = repo.changectx(rev).manifest()
1190 matches[rev] = {} 1188 matches[rev] = {}
1191 for fn in fns: 1189 for fn in fns:
1207 copy = copies.get(rev, {}).get(fn) 1205 copy = copies.get(rev, {}).get(fn)
1208 if fn in skip: 1206 if fn in skip:
1209 if copy: 1207 if copy:
1210 skip[copy] = True 1208 skip[copy] = True
1211 continue 1209 continue
1212 if incrementing or not opts['all'] or fstate[fn]: 1210 if not opts['all'] or fstate[fn]:
1213 pos, neg = display(fn, rev, m, fstate[fn]) 1211 pos, neg = display(fn, rev, m, fstate[fn])
1214 count += pos + neg 1212 count += pos + neg
1215 if pos and not opts['all']: 1213 if pos and not opts['all']:
1216 skip[fn] = True 1214 skip[fn] = True
1217 if copy: 1215 if copy:
1219 fstate[fn] = m 1217 fstate[fn] = m
1220 if copy: 1218 if copy:
1221 fstate[copy] = m 1219 fstate[copy] = m
1222 prev[fn] = rev 1220 prev[fn] = rev
1223 1221
1224 if not incrementing: 1222 fstate = fstate.items()
1225 fstate = fstate.items() 1223 fstate.sort()
1226 fstate.sort() 1224 for fn, state in fstate:
1227 for fn, state in fstate: 1225 if fn in skip:
1228 if fn in skip: 1226 continue
1229 continue 1227 if fn not in copies.get(prev[fn], {}):
1230 if fn not in copies.get(prev[fn], {}): 1228 display(fn, rev, {}, state)
1231 display(fn, rev, {}, state)
1232 return (count == 0 and 1) or 0 1229 return (count == 0 and 1) or 0
1233 1230
1234 def heads(ui, repo, **opts): 1231 def heads(ui, repo, **opts):
1235 """show current repository heads 1232 """show current repository heads
1236 1233