##// END OF EJS Templates
cmdutil: use context objects for walkchangerevs()
Dirkjan Ochtman -
r9367:1ef63045 default
parent child Browse files
Show More
@@ -53,15 +53,17 b' def countrate(ui, repo, amap, *pats, **o'
53 53 if opts.get('date'):
54 54 df = util.matchdate(opts['date'])
55 55
56 get = util.cachefunc(lambda r: repo[r].changeset())
56 get = util.cachefunc(lambda r: repo[r])
57 57 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
58 58 for st, rev, fns in changeiter:
59
59 60 if not st == 'add':
60 61 continue
61 if df and not df(get(rev)[2][0]): # doesn't match date format
62
63 ctx = get(rev)
64 if df and not df(ctx.date()[0]): # doesn't match date format
62 65 continue
63 66
64 ctx = repo[rev]
65 67 key = getkey(ctx)
66 68 key = amap.get(key, key) # alias remap
67 69 if opts.get('changesets'):
@@ -987,12 +987,12 b' def show_changeset(ui, repo, opts, buffe'
987 987 def finddate(ui, repo, date):
988 988 """Find the tipmost changeset that matches the given date spec"""
989 989 df = util.matchdate(date)
990 get = util.cachefunc(lambda r: repo[r].changeset())
990 get = util.cachefunc(lambda r: repo[r])
991 991 changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None})
992 992 results = {}
993 993 for st, rev, fns in changeiter:
994 994 if st == 'add':
995 d = get(rev)[2]
995 d = get(rev).date()
996 996 if df(d[0]):
997 997 results[rev] = d
998 998 elif st == 'iter':
@@ -1118,13 +1118,13 b' def walkchangerevs(ui, repo, pats, chang'
1118 1118 def changerevgen():
1119 1119 for i, window in increasing_windows(len(repo) - 1, nullrev):
1120 1120 for j in xrange(i - window, i + 1):
1121 yield j, change(j)[3]
1121 yield change(j)
1122 1122
1123 for rev, changefiles in changerevgen():
1124 matches = filter(m, changefiles)
1123 for ctx in changerevgen():
1124 matches = filter(m, ctx.files())
1125 1125 if matches:
1126 fncache[rev] = matches
1127 wanted.add(rev)
1126 fncache[ctx.rev()] = matches
1127 wanted.add(ctx.rev())
1128 1128
1129 1129 class followfilter(object):
1130 1130 def __init__(self, onlyfirst=False):
@@ -1189,7 +1189,7 b' def walkchangerevs(ui, repo, pats, chang'
1189 1189 fns = fncache.get(rev)
1190 1190 if not fns:
1191 1191 def fns_generator():
1192 for f in change(rev)[3]:
1192 for f in change(rev).files():
1193 1193 if m(f):
1194 1194 yield f
1195 1195 fns = fns_generator()
@@ -1275,9 +1275,9 b' def grep(ui, repo, pattern, *pats, **opt'
1275 1275 if opts.get('all'):
1276 1276 cols.append(change)
1277 1277 if opts.get('user'):
1278 cols.append(ui.shortuser(get(r)[1]))
1278 cols.append(ui.shortuser(get(r).user()))
1279 1279 if opts.get('date'):
1280 cols.append(datefunc(get(r)[2]))
1280 cols.append(datefunc(get(r).date()))
1281 1281 if opts.get('files_with_matches'):
1282 1282 c = (fn, r)
1283 1283 if c in filerevmatches:
@@ -1291,7 +1291,7 b' def grep(ui, repo, pattern, *pats, **opt'
1291 1291
1292 1292 skip = {}
1293 1293 revfiles = {}
1294 get = util.cachefunc(lambda r: repo[r].changeset())
1294 get = util.cachefunc(lambda r: repo[r])
1295 1295 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1296 1296 found = False
1297 1297 follow = opts.get('follow')
@@ -1300,7 +1300,7 b' def grep(ui, repo, pattern, *pats, **opt'
1300 1300 matches.clear()
1301 1301 revfiles.clear()
1302 1302 elif st == 'add':
1303 ctx = repo[rev]
1303 ctx = get(rev)
1304 1304 pctx = ctx.parents()[0]
1305 1305 parent = pctx.rev()
1306 1306 matches.setdefault(rev, {})
@@ -1334,7 +1334,7 b' def grep(ui, repo, pattern, *pats, **opt'
1334 1334 except error.LookupError:
1335 1335 pass
1336 1336 elif st == 'iter':
1337 parent = repo[rev].parents()[0].rev()
1337 parent = get(rev).parents()[0].rev()
1338 1338 for fn in sorted(revfiles.get(rev, [])):
1339 1339 states = matches[rev][fn]
1340 1340 copy = copies.get(rev, {}).get(fn)
@@ -1982,7 +1982,7 b' def log(ui, repo, *pats, **opts):'
1982 1982 will appear in files:.
1983 1983 """
1984 1984
1985 get = util.cachefunc(lambda r: repo[r].changeset())
1985 get = util.cachefunc(lambda r: repo[r])
1986 1986 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1987 1987
1988 1988 limit = cmdutil.loglimit(opts)
@@ -2040,40 +2040,37 b' def log(ui, repo, *pats, **opts):'
2040 2040 if opts.get('only_merges') and len(parents) != 2:
2041 2041 continue
2042 2042
2043 if only_branches:
2044 revbranch = get(rev)[5]['branch']
2045 if revbranch not in only_branches:
2046 continue
2047
2048 if df:
2049 changes = get(rev)
2050 if not df(changes[2][0]):
2051 continue
2043 ctx = get(rev)
2044 if only_branches and ctx.branch() not in only_branches:
2045 continue
2046
2047 if df and not df(ctx.date()):
2048 continue
2052 2049
2053 2050 if opts.get('keyword'):
2054 changes = get(rev)
2055 2051 miss = 0
2056 2052 for k in [kw.lower() for kw in opts['keyword']]:
2057 if not (k in changes[1].lower() or
2058 k in changes[4].lower() or
2059 k in " ".join(changes[3]).lower()):
2053 if not (k in ctx.user().lower() or
2054 k in ctx.description().lower() or
2055 k in " ".join(ctx.files()[3]).lower()):
2060 2056 miss = 1
2061 2057 break
2062 2058 if miss:
2063 2059 continue
2064 2060
2065 2061 if opts['user']:
2066 changes = get(rev)
2067 if not [k for k in opts['user'] if k in changes[1]]:
2062 if not [k for k in opts['user'] if k in ctx.user()]:
2068 2063 continue
2069 2064
2070 2065 copies = []
2071 2066 if opts.get('copies') and rev:
2072 for fn in get(rev)[3]:
2067 for fn in ctx.files():
2073 2068 rename = getrenamed(fn, rev)
2074 2069 if rename:
2075 2070 copies.append((fn, rename[0]))
2076 displayer.show(context.changectx(repo, rev), copies=copies)
2071
2072 displayer.show(ctx, copies=copies)
2073
2077 2074 elif st == 'iter':
2078 2075 if count == limit: break
2079 2076 if displayer.flush(rev):
@@ -22,14 +22,14 b" hg grep '**test**'"
22 22 echo % simple
23 23 hg grep port port
24 24 echo % all
25 hg grep --all -nu port port
25 hg grep --traceback --all -nu port port
26 26 echo % other
27 27 hg grep import port
28 28
29 29 hg cp port port2
30 30 hg commit -m 4 -u spam -d '5 0'
31 echo '% follow'
32 hg grep -f 'import$' port2
31 echo % follow
32 hg grep --traceback -f 'import$' port2
33 33 echo deport >> port2
34 34 hg commit -m 5 -u eggs -d '6 0'
35 35 hg grep -f --all -nu port port2
General Comments 0
You need to be logged in to leave comments. Login now