Show More
@@ -54,13 +54,10 b' def countrate(ui, repo, amap, *pats, **o' | |||
|
54 | 54 | df = util.matchdate(opts['date']) |
|
55 | 55 | |
|
56 | 56 | m = cmdutil.match(repo, pats, opts) |
|
57 | for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, m, opts): | |
|
58 | if not st == 'add': | |
|
59 | continue | |
|
60 | ||
|
57 | def prep(ctx, fns): | |
|
61 | 58 | rev = ctx.rev() |
|
62 | 59 | if df and not df(ctx.date()[0]): # doesn't match date format |
|
63 |
|
|
|
60 | return | |
|
64 | 61 | |
|
65 | 62 | key = getkey(ctx) |
|
66 | 63 | key = amap.get(key, key) # alias remap |
@@ -70,7 +67,7 b' def countrate(ui, repo, amap, *pats, **o' | |||
|
70 | 67 | parents = ctx.parents() |
|
71 | 68 | if len(parents) > 1: |
|
72 | 69 | ui.note(_('Revision %d is a merge, ignoring...\n') % (rev,)) |
|
73 |
|
|
|
70 | return | |
|
74 | 71 | |
|
75 | 72 | ctx1 = parents[0] |
|
76 | 73 | lines = changedlines(ui, repo, ctx1, ctx, fns) |
@@ -84,6 +81,9 b' def countrate(ui, repo, amap, *pats, **o' | |||
|
84 | 81 | ui.write("\r" + _("generating stats: %d%%") % pct) |
|
85 | 82 | sys.stdout.flush() |
|
86 | 83 | |
|
84 | for ctx in cmdutil.walkchangerevs(ui, repo, m, opts, prep): | |
|
85 | continue | |
|
86 | ||
|
87 | 87 | if opts.get('progress'): |
|
88 | 88 | ui.write("\r") |
|
89 | 89 | sys.stdout.flush() |
@@ -1023,15 +1023,16 b' def show_changeset(ui, repo, opts, buffe' | |||
|
1023 | 1023 | def finddate(ui, repo, date): |
|
1024 | 1024 | """Find the tipmost changeset that matches the given date spec""" |
|
1025 | 1025 | df = util.matchdate(date) |
|
1026 | get = util.cachefunc(lambda r: repo[r]) | |
|
1027 | 1026 | m = matchall(repo) |
|
1028 | 1027 | results = {} |
|
1029 | for st, rev, fns in walkchangerevs(ui, repo, m, get, {'rev':None}): | |
|
1030 | if st == 'add': | |
|
1031 |
|
|
|
1028 | ||
|
1029 | def prep(ctx, fns): | |
|
1030 | d = ctx.date() | |
|
1032 | 1031 |
|
|
1033 | 1032 |
|
|
1034 | elif st == 'iter': | |
|
1033 | ||
|
1034 | for ctx in walkchangerevs(ui, repo, m, {'rev':None}, prep): | |
|
1035 | rev = ctx.rev() | |
|
1035 | 1036 |
|
|
1036 | 1037 |
|
|
1037 | 1038 |
|
@@ -1039,7 +1040,7 b' def finddate(ui, repo, date):' | |||
|
1039 | 1040 | |
|
1040 | 1041 | raise util.Abort(_("revision matching date not found")) |
|
1041 | 1042 | |
|
1042 | def walkchangerevs(ui, repo, match, opts): | |
|
1043 | def walkchangerevs(ui, repo, match, opts, prepare): | |
|
1043 | 1044 | '''Iterate over files and the revs in which they changed. |
|
1044 | 1045 | |
|
1045 | 1046 | Callers most commonly need to iterate backwards over the history |
@@ -1050,15 +1051,9 b' def walkchangerevs(ui, repo, match, opts' | |||
|
1050 | 1051 | window, we first walk forwards to gather data, then in the desired |
|
1051 | 1052 | order (usually backwards) to display it. |
|
1052 | 1053 | |
|
1053 |
This function returns an iterator |
|
|
1054 | They will be of one of the following forms: | |
|
1055 | ||
|
1056 | "add", rev, fns: out-of-order traversal of the given filenames | |
|
1057 | fns, which changed during revision rev - use to gather data for | |
|
1058 | possible display | |
|
1059 | ||
|
1060 | "iter", rev, None: in-order traversal of the revs earlier iterated | |
|
1061 | over with "add" - use to display data''' | |
|
1054 | This function returns an iterator yielding contexts. Before | |
|
1055 | yielding each context, the iterator will first call the prepare | |
|
1056 | function on each context in the window in forward order.''' | |
|
1062 | 1057 | |
|
1063 | 1058 | def increasing_windows(start, end, windowsize=8, sizelimit=512): |
|
1064 | 1059 | if start < end: |
@@ -1225,9 +1220,9 b' def walkchangerevs(ui, repo, match, opts' | |||
|
1225 | 1220 | if match(f): |
|
1226 | 1221 | yield f |
|
1227 | 1222 | fns = fns_generator() |
|
1228 |
|
|
|
1223 | prepare(ctx, fns) | |
|
1229 | 1224 | for rev in nrevs: |
|
1230 |
yield |
|
|
1225 | yield change(rev) | |
|
1231 | 1226 | return iterate() |
|
1232 | 1227 | |
|
1233 | 1228 | def commit(ui, repo, commitfunc, pats, opts): |
@@ -1302,8 +1302,8 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
1302 | 1302 | matchfn = cmdutil.match(repo, pats, opts) |
|
1303 | 1303 | found = False |
|
1304 | 1304 | follow = opts.get('follow') |
|
1305 | for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, opts): | |
|
1306 | if st == 'add': | |
|
1305 | ||
|
1306 | def prep(ctx, fns): | |
|
1307 | 1307 |
|
|
1308 | 1308 |
|
|
1309 | 1309 |
|
@@ -1337,7 +1337,8 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
1337 | 1337 |
|
|
1338 | 1338 |
|
|
1339 | 1339 |
|
|
1340 | elif st == 'iter': | |
|
1340 | ||
|
1341 | for ctx in cmdutil.walkchangerevs(ui, repo, matchfn, opts, prep): | |
|
1341 | 1342 |
|
|
1342 | 1343 |
|
|
1343 | 1344 |
|
@@ -2037,21 +2038,18 b' def log(ui, repo, *pats, **opts):' | |||
|
2037 | 2038 | only_branches = opts.get('only_branch') |
|
2038 | 2039 | |
|
2039 | 2040 | displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) |
|
2040 | for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, opts): | |
|
2041 | def prep(ctx, fns): | |
|
2041 | 2042 | rev = ctx.rev() |
|
2042 | if st == 'add': | |
|
2043 | 2043 |
|
|
2044 | 2044 |
|
|
2045 | 2045 |
|
|
2046 |
|
|
|
2046 | return | |
|
2047 | 2047 |
|
|
2048 |
|
|
|
2049 | ||
|
2048 | return | |
|
2050 | 2049 |
|
|
2051 |
|
|
|
2052 | ||
|
2050 | return | |
|
2053 | 2051 |
|
|
2054 |
|
|
|
2052 | return | |
|
2055 | 2053 | |
|
2056 | 2054 |
|
|
2057 | 2055 |
|
@@ -2062,11 +2060,11 b' def log(ui, repo, *pats, **opts):' | |||
|
2062 | 2060 |
|
|
2063 | 2061 |
|
|
2064 | 2062 |
|
|
2065 |
|
|
|
2063 | return | |
|
2066 | 2064 | |
|
2067 | 2065 |
|
|
2068 | 2066 |
|
|
2069 |
|
|
|
2067 | return | |
|
2070 | 2068 | |
|
2071 | 2069 |
|
|
2072 | 2070 |
|
@@ -2077,10 +2075,9 b' def log(ui, repo, *pats, **opts):' | |||
|
2077 | 2075 | |
|
2078 | 2076 |
|
|
2079 | 2077 | |
|
2080 | elif st == 'iter': | |
|
2081 |
|
|
|
2082 | ||
|
2083 | if displayer.flush(rev): | |
|
2078 | for ctx in cmdutil.walkchangerevs(ui, repo, matchfn, opts, prep): | |
|
2079 | if count != limit: | |
|
2080 | if displayer.flush(ctx.rev()): | |
|
2084 | 2081 | count += 1 |
|
2085 | 2082 | |
|
2086 | 2083 | def manifest(ui, repo, node=None, rev=None): |
General Comments 0
You need to be logged in to leave comments.
Login now