Show More
@@ -54,13 +54,10 b' def countrate(ui, repo, amap, *pats, **o' | |||||
54 | df = util.matchdate(opts['date']) |
|
54 | df = util.matchdate(opts['date']) | |
55 |
|
55 | |||
56 | m = cmdutil.match(repo, pats, opts) |
|
56 | m = cmdutil.match(repo, pats, opts) | |
57 | for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, m, opts): |
|
57 | def prep(ctx, fns): | |
58 | if not st == 'add': |
|
|||
59 | continue |
|
|||
60 |
|
||||
61 | rev = ctx.rev() |
|
58 | rev = ctx.rev() | |
62 | if df and not df(ctx.date()[0]): # doesn't match date format |
|
59 | if df and not df(ctx.date()[0]): # doesn't match date format | |
63 |
|
|
60 | return | |
64 |
|
61 | |||
65 | key = getkey(ctx) |
|
62 | key = getkey(ctx) | |
66 | key = amap.get(key, key) # alias remap |
|
63 | key = amap.get(key, key) # alias remap | |
@@ -70,7 +67,7 b' def countrate(ui, repo, amap, *pats, **o' | |||||
70 | parents = ctx.parents() |
|
67 | parents = ctx.parents() | |
71 | if len(parents) > 1: |
|
68 | if len(parents) > 1: | |
72 | ui.note(_('Revision %d is a merge, ignoring...\n') % (rev,)) |
|
69 | ui.note(_('Revision %d is a merge, ignoring...\n') % (rev,)) | |
73 |
|
|
70 | return | |
74 |
|
71 | |||
75 | ctx1 = parents[0] |
|
72 | ctx1 = parents[0] | |
76 | lines = changedlines(ui, repo, ctx1, ctx, fns) |
|
73 | lines = changedlines(ui, repo, ctx1, ctx, fns) | |
@@ -84,6 +81,9 b' def countrate(ui, repo, amap, *pats, **o' | |||||
84 | ui.write("\r" + _("generating stats: %d%%") % pct) |
|
81 | ui.write("\r" + _("generating stats: %d%%") % pct) | |
85 | sys.stdout.flush() |
|
82 | sys.stdout.flush() | |
86 |
|
83 | |||
|
84 | for ctx in cmdutil.walkchangerevs(ui, repo, m, opts, prep): | |||
|
85 | continue | |||
|
86 | ||||
87 | if opts.get('progress'): |
|
87 | if opts.get('progress'): | |
88 | ui.write("\r") |
|
88 | ui.write("\r") | |
89 | sys.stdout.flush() |
|
89 | sys.stdout.flush() |
@@ -1023,23 +1023,24 b' def show_changeset(ui, repo, opts, buffe' | |||||
1023 | def finddate(ui, repo, date): |
|
1023 | def finddate(ui, repo, date): | |
1024 | """Find the tipmost changeset that matches the given date spec""" |
|
1024 | """Find the tipmost changeset that matches the given date spec""" | |
1025 | df = util.matchdate(date) |
|
1025 | df = util.matchdate(date) | |
1026 | get = util.cachefunc(lambda r: repo[r]) |
|
|||
1027 | m = matchall(repo) |
|
1026 | m = matchall(repo) | |
1028 | results = {} |
|
1027 | results = {} | |
1029 | for st, rev, fns in walkchangerevs(ui, repo, m, get, {'rev':None}): |
|
1028 | ||
1030 | if st == 'add': |
|
1029 | def prep(ctx, fns): | |
1031 |
|
|
1030 | d = ctx.date() | |
1032 |
|
|
1031 | if df(d[0]): | |
1033 |
|
|
1032 | results[rev] = d | |
1034 | elif st == 'iter': |
|
1033 | ||
1035 | if rev in results: |
|
1034 | for ctx in walkchangerevs(ui, repo, m, {'rev':None}, prep): | |
1036 | ui.status(_("Found revision %s from %s\n") % |
|
1035 | rev = ctx.rev() | |
1037 | (rev, util.datestr(results[rev]))) |
|
1036 | if rev in results: | |
1038 | return str(rev) |
|
1037 | ui.status(_("Found revision %s from %s\n") % | |
|
1038 | (rev, util.datestr(results[rev]))) | |||
|
1039 | return str(rev) | |||
1039 |
|
1040 | |||
1040 | raise util.Abort(_("revision matching date not found")) |
|
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 | '''Iterate over files and the revs in which they changed. |
|
1044 | '''Iterate over files and the revs in which they changed. | |
1044 |
|
1045 | |||
1045 | Callers most commonly need to iterate backwards over the history |
|
1046 | Callers most commonly need to iterate backwards over the history | |
@@ -1050,15 +1051,9 b' def walkchangerevs(ui, repo, match, opts' | |||||
1050 | window, we first walk forwards to gather data, then in the desired |
|
1051 | window, we first walk forwards to gather data, then in the desired | |
1051 | order (usually backwards) to display it. |
|
1052 | order (usually backwards) to display it. | |
1052 |
|
1053 | |||
1053 |
This function returns an iterator |
|
1054 | This function returns an iterator yielding contexts. Before | |
1054 | They will be of one of the following forms: |
|
1055 | yielding each context, the iterator will first call the prepare | |
1055 |
|
1056 | function on each context in the window in forward order.''' | ||
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''' |
|
|||
1062 |
|
1057 | |||
1063 | def increasing_windows(start, end, windowsize=8, sizelimit=512): |
|
1058 | def increasing_windows(start, end, windowsize=8, sizelimit=512): | |
1064 | if start < end: |
|
1059 | if start < end: | |
@@ -1225,9 +1220,9 b' def walkchangerevs(ui, repo, match, opts' | |||||
1225 | if match(f): |
|
1220 | if match(f): | |
1226 | yield f |
|
1221 | yield f | |
1227 | fns = fns_generator() |
|
1222 | fns = fns_generator() | |
1228 |
|
|
1223 | prepare(ctx, fns) | |
1229 | for rev in nrevs: |
|
1224 | for rev in nrevs: | |
1230 |
yield |
|
1225 | yield change(rev) | |
1231 | return iterate() |
|
1226 | return iterate() | |
1232 |
|
1227 | |||
1233 | def commit(ui, repo, commitfunc, pats, opts): |
|
1228 | def commit(ui, repo, commitfunc, pats, opts): |
@@ -1302,61 +1302,62 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
1302 | matchfn = cmdutil.match(repo, pats, opts) |
|
1302 | matchfn = cmdutil.match(repo, pats, opts) | |
1303 | found = False |
|
1303 | found = False | |
1304 | follow = opts.get('follow') |
|
1304 | follow = opts.get('follow') | |
1305 | for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, opts): |
|
1305 | ||
1306 | if st == 'add': |
|
1306 | def prep(ctx, fns): | |
1307 |
|
|
1307 | rev = ctx.rev() | |
1308 |
|
|
1308 | pctx = ctx.parents()[0] | |
1309 |
|
|
1309 | parent = pctx.rev() | |
1310 |
|
|
1310 | matches.setdefault(rev, {}) | |
1311 |
|
|
1311 | matches.setdefault(parent, {}) | |
1312 |
|
|
1312 | files = revfiles.setdefault(rev, []) | |
1313 |
|
|
1313 | for fn in fns: | |
1314 |
|
|
1314 | flog = getfile(fn) | |
|
1315 | try: | |||
|
1316 | fnode = ctx.filenode(fn) | |||
|
1317 | except error.LookupError: | |||
|
1318 | continue | |||
|
1319 | ||||
|
1320 | copied = flog.renamed(fnode) | |||
|
1321 | copy = follow and copied and copied[0] | |||
|
1322 | if copy: | |||
|
1323 | copies.setdefault(rev, {})[fn] = copy | |||
|
1324 | if fn in skip: | |||
|
1325 | if copy: | |||
|
1326 | skip[copy] = True | |||
|
1327 | continue | |||
|
1328 | files.append(fn) | |||
|
1329 | ||||
|
1330 | if fn not in matches[rev]: | |||
|
1331 | grepbody(fn, rev, flog.read(fnode)) | |||
|
1332 | ||||
|
1333 | pfn = copy or fn | |||
|
1334 | if pfn not in matches[parent]: | |||
1315 | try: |
|
1335 | try: | |
1316 | fnode = ctx.filenode(fn) |
|
1336 | fnode = pctx.filenode(pfn) | |
|
1337 | grepbody(pfn, parent, flog.read(fnode)) | |||
1317 | except error.LookupError: |
|
1338 | except error.LookupError: | |
1318 |
|
|
1339 | pass | |
1319 |
|
1340 | |||
1320 | copied = flog.renamed(fnode) |
|
1341 | for ctx in cmdutil.walkchangerevs(ui, repo, matchfn, opts, prep): | |
1321 | copy = follow and copied and copied[0] |
|
1342 | rev = ctx.rev() | |
|
1343 | parent = ctx.parents()[0].rev() | |||
|
1344 | for fn in sorted(revfiles.get(rev, [])): | |||
|
1345 | states = matches[rev][fn] | |||
|
1346 | copy = copies.get(rev, {}).get(fn) | |||
|
1347 | if fn in skip: | |||
1322 | if copy: |
|
1348 | if copy: | |
1323 | copies.setdefault(rev, {})[fn] = copy |
|
1349 | skip[copy] = True | |
1324 |
|
|
1350 | continue | |
|
1351 | pstates = matches.get(parent, {}).get(copy or fn, []) | |||
|
1352 | if pstates or states: | |||
|
1353 | r = display(fn, ctx, pstates, states) | |||
|
1354 | found = found or r | |||
|
1355 | if r and not opts.get('all'): | |||
|
1356 | skip[fn] = True | |||
1325 | if copy: |
|
1357 | if copy: | |
1326 | skip[copy] = True |
|
1358 | skip[copy] = True | |
1327 | continue |
|
1359 | del matches[rev] | |
1328 | files.append(fn) |
|
1360 | del revfiles[rev] | |
1329 |
|
||||
1330 | if fn not in matches[rev]: |
|
|||
1331 | grepbody(fn, rev, flog.read(fnode)) |
|
|||
1332 |
|
||||
1333 | pfn = copy or fn |
|
|||
1334 | if pfn not in matches[parent]: |
|
|||
1335 | try: |
|
|||
1336 | fnode = pctx.filenode(pfn) |
|
|||
1337 | grepbody(pfn, parent, flog.read(fnode)) |
|
|||
1338 | except error.LookupError: |
|
|||
1339 | pass |
|
|||
1340 | elif st == 'iter': |
|
|||
1341 | rev = ctx.rev() |
|
|||
1342 | parent = ctx.parents()[0].rev() |
|
|||
1343 | for fn in sorted(revfiles.get(rev, [])): |
|
|||
1344 | states = matches[rev][fn] |
|
|||
1345 | copy = copies.get(rev, {}).get(fn) |
|
|||
1346 | if fn in skip: |
|
|||
1347 | if copy: |
|
|||
1348 | skip[copy] = True |
|
|||
1349 | continue |
|
|||
1350 | pstates = matches.get(parent, {}).get(copy or fn, []) |
|
|||
1351 | if pstates or states: |
|
|||
1352 | r = display(fn, ctx, pstates, states) |
|
|||
1353 | found = found or r |
|
|||
1354 | if r and not opts.get('all'): |
|
|||
1355 | skip[fn] = True |
|
|||
1356 | if copy: |
|
|||
1357 | skip[copy] = True |
|
|||
1358 | del matches[rev] |
|
|||
1359 | del revfiles[rev] |
|
|||
1360 |
|
1361 | |||
1361 | def heads(ui, repo, *branchrevs, **opts): |
|
1362 | def heads(ui, repo, *branchrevs, **opts): | |
1362 | """show current repository heads or show branch heads |
|
1363 | """show current repository heads or show branch heads | |
@@ -2037,50 +2038,46 b' def log(ui, repo, *pats, **opts):' | |||||
2037 | only_branches = opts.get('only_branch') |
|
2038 | only_branches = opts.get('only_branch') | |
2038 |
|
2039 | |||
2039 | displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) |
|
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 | rev = ctx.rev() |
|
2042 | rev = ctx.rev() | |
2042 | if st == 'add': |
|
2043 | parents = [p for p in repo.changelog.parentrevs(rev) | |
2043 | parents = [p for p in repo.changelog.parentrevs(rev) |
|
2044 | if p != nullrev] | |
2044 | if p != nullrev] |
|
2045 | if opts.get('no_merges') and len(parents) == 2: | |
2045 | if opts.get('no_merges') and len(parents) == 2: |
|
2046 | return | |
2046 | continue |
|
2047 | if opts.get('only_merges') and len(parents) != 2: | |
2047 | if opts.get('only_merges') and len(parents) != 2: |
|
2048 | return | |
2048 | continue |
|
2049 | if only_branches and ctx.branch() not in only_branches: | |
2049 |
|
2050 | return | ||
2050 | if only_branches and ctx.branch() not in only_branches: |
|
2051 | if df and not df(ctx.date()[0]): | |
2051 |
|
|
2052 | return | |
2052 |
|
2053 | |||
2053 | if df and not df(ctx.date()[0]): |
|
2054 | if opts.get('keyword'): | |
2054 |
|
|
2055 | miss = 0 | |
2055 |
|
2056 | for k in [kw.lower() for kw in opts['keyword']]: | ||
2056 | if opts.get('keyword'): |
|
2057 | if not (k in ctx.user().lower() or | |
2057 | miss = 0 |
|
2058 | k in ctx.description().lower() or | |
2058 | for k in [kw.lower() for kw in opts['keyword']]: |
|
2059 | k in " ".join(ctx.files()).lower()): | |
2059 | if not (k in ctx.user().lower() or |
|
2060 | miss = 1 | |
2060 | k in ctx.description().lower() or |
|
2061 | break | |
2061 | k in " ".join(ctx.files()).lower()): |
|
2062 | if miss: | |
2062 | miss = 1 |
|
2063 | return | |
2063 | break |
|
2064 | ||
2064 | if miss: |
|
2065 | if opts['user']: | |
2065 | continue |
|
2066 | if not [k for k in opts['user'] if k in ctx.user()]: | |
2066 |
|
2067 | return | ||
2067 | if opts['user']: |
|
2068 | ||
2068 | if not [k for k in opts['user'] if k in ctx.user()]: |
|
2069 | copies = [] | |
2069 | continue |
|
2070 | if opts.get('copies') and rev: | |
2070 |
|
2071 | for fn in ctx.files(): | ||
2071 | copies = [] |
|
2072 | rename = getrenamed(fn, rev) | |
2072 | if opts.get('copies') and rev: |
|
2073 | if rename: | |
2073 | for fn in ctx.files(): |
|
2074 | copies.append((fn, rename[0])) | |
2074 | rename = getrenamed(fn, rev) |
|
2075 | ||
2075 | if rename: |
|
2076 | displayer.show(ctx, copies=copies) | |
2076 | copies.append((fn, rename[0])) |
|
2077 | ||
2077 |
|
2078 | for ctx in cmdutil.walkchangerevs(ui, repo, matchfn, opts, prep): | ||
2078 | displayer.show(ctx, copies=copies) |
|
2079 | if count != limit: | |
2079 |
|
2080 | if displayer.flush(ctx.rev()): | ||
2080 | elif st == 'iter': |
|
|||
2081 | if count == limit: break |
|
|||
2082 |
|
||||
2083 | if displayer.flush(rev): |
|
|||
2084 | count += 1 |
|
2081 | count += 1 | |
2085 |
|
2082 | |||
2086 | def manifest(ui, repo, node=None, rev=None): |
|
2083 | def manifest(ui, repo, node=None, rev=None): |
General Comments 0
You need to be logged in to leave comments.
Login now