Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 9367:1ef630452e0b
cmdutil: use context objects for walkchangerevs()
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 20 Aug 2009 08:34:22 +0200 |
parents | b694531a5aa7 |
children | b34184c046ac |
comparison
equal
deleted
inserted
replaced
9366:9ff178e7b627 | 9367:1ef630452e0b |
---|---|
1273 if opts.get('line_number'): | 1273 if opts.get('line_number'): |
1274 cols.append(str(l.linenum)) | 1274 cols.append(str(l.linenum)) |
1275 if opts.get('all'): | 1275 if opts.get('all'): |
1276 cols.append(change) | 1276 cols.append(change) |
1277 if opts.get('user'): | 1277 if opts.get('user'): |
1278 cols.append(ui.shortuser(get(r)[1])) | 1278 cols.append(ui.shortuser(get(r).user())) |
1279 if opts.get('date'): | 1279 if opts.get('date'): |
1280 cols.append(datefunc(get(r)[2])) | 1280 cols.append(datefunc(get(r).date())) |
1281 if opts.get('files_with_matches'): | 1281 if opts.get('files_with_matches'): |
1282 c = (fn, r) | 1282 c = (fn, r) |
1283 if c in filerevmatches: | 1283 if c in filerevmatches: |
1284 continue | 1284 continue |
1285 filerevmatches[c] = 1 | 1285 filerevmatches[c] = 1 |
1289 found = True | 1289 found = True |
1290 return found | 1290 return found |
1291 | 1291 |
1292 skip = {} | 1292 skip = {} |
1293 revfiles = {} | 1293 revfiles = {} |
1294 get = util.cachefunc(lambda r: repo[r].changeset()) | 1294 get = util.cachefunc(lambda r: repo[r]) |
1295 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) | 1295 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) |
1296 found = False | 1296 found = False |
1297 follow = opts.get('follow') | 1297 follow = opts.get('follow') |
1298 for st, rev, fns in changeiter: | 1298 for st, rev, fns in changeiter: |
1299 if st == 'window': | 1299 if st == 'window': |
1300 matches.clear() | 1300 matches.clear() |
1301 revfiles.clear() | 1301 revfiles.clear() |
1302 elif st == 'add': | 1302 elif st == 'add': |
1303 ctx = repo[rev] | 1303 ctx = get(rev) |
1304 pctx = ctx.parents()[0] | 1304 pctx = ctx.parents()[0] |
1305 parent = pctx.rev() | 1305 parent = pctx.rev() |
1306 matches.setdefault(rev, {}) | 1306 matches.setdefault(rev, {}) |
1307 matches.setdefault(parent, {}) | 1307 matches.setdefault(parent, {}) |
1308 files = revfiles.setdefault(rev, []) | 1308 files = revfiles.setdefault(rev, []) |
1332 fnode = pctx.filenode(pfn) | 1332 fnode = pctx.filenode(pfn) |
1333 grepbody(pfn, parent, flog.read(fnode)) | 1333 grepbody(pfn, parent, flog.read(fnode)) |
1334 except error.LookupError: | 1334 except error.LookupError: |
1335 pass | 1335 pass |
1336 elif st == 'iter': | 1336 elif st == 'iter': |
1337 parent = repo[rev].parents()[0].rev() | 1337 parent = get(rev).parents()[0].rev() |
1338 for fn in sorted(revfiles.get(rev, [])): | 1338 for fn in sorted(revfiles.get(rev, [])): |
1339 states = matches[rev][fn] | 1339 states = matches[rev][fn] |
1340 copy = copies.get(rev, {}).get(fn) | 1340 copy = copies.get(rev, {}).get(fn) |
1341 if fn in skip: | 1341 if fn in skip: |
1342 if copy: | 1342 if copy: |
1980 changesets, as it will only compare the merge changeset against | 1980 changesets, as it will only compare the merge changeset against |
1981 its first parent. Also, only files different from BOTH parents | 1981 its first parent. Also, only files different from BOTH parents |
1982 will appear in files:. | 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 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) | 1986 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) |
1987 | 1987 |
1988 limit = cmdutil.loglimit(opts) | 1988 limit = cmdutil.loglimit(opts) |
1989 count = 0 | 1989 count = 0 |
1990 | 1990 |
2038 if opts.get('no_merges') and len(parents) == 2: | 2038 if opts.get('no_merges') and len(parents) == 2: |
2039 continue | 2039 continue |
2040 if opts.get('only_merges') and len(parents) != 2: | 2040 if opts.get('only_merges') and len(parents) != 2: |
2041 continue | 2041 continue |
2042 | 2042 |
2043 if only_branches: | 2043 ctx = get(rev) |
2044 revbranch = get(rev)[5]['branch'] | 2044 if only_branches and ctx.branch() not in only_branches: |
2045 if revbranch not in only_branches: | 2045 continue |
2046 continue | 2046 |
2047 | 2047 if df and not df(ctx.date()): |
2048 if df: | 2048 continue |
2049 changes = get(rev) | |
2050 if not df(changes[2][0]): | |
2051 continue | |
2052 | 2049 |
2053 if opts.get('keyword'): | 2050 if opts.get('keyword'): |
2054 changes = get(rev) | |
2055 miss = 0 | 2051 miss = 0 |
2056 for k in [kw.lower() for kw in opts['keyword']]: | 2052 for k in [kw.lower() for kw in opts['keyword']]: |
2057 if not (k in changes[1].lower() or | 2053 if not (k in ctx.user().lower() or |
2058 k in changes[4].lower() or | 2054 k in ctx.description().lower() or |
2059 k in " ".join(changes[3]).lower()): | 2055 k in " ".join(ctx.files()[3]).lower()): |
2060 miss = 1 | 2056 miss = 1 |
2061 break | 2057 break |
2062 if miss: | 2058 if miss: |
2063 continue | 2059 continue |
2064 | 2060 |
2065 if opts['user']: | 2061 if opts['user']: |
2066 changes = get(rev) | 2062 if not [k for k in opts['user'] if k in ctx.user()]: |
2067 if not [k for k in opts['user'] if k in changes[1]]: | |
2068 continue | 2063 continue |
2069 | 2064 |
2070 copies = [] | 2065 copies = [] |
2071 if opts.get('copies') and rev: | 2066 if opts.get('copies') and rev: |
2072 for fn in get(rev)[3]: | 2067 for fn in ctx.files(): |
2073 rename = getrenamed(fn, rev) | 2068 rename = getrenamed(fn, rev) |
2074 if rename: | 2069 if rename: |
2075 copies.append((fn, rename[0])) | 2070 copies.append((fn, rename[0])) |
2076 displayer.show(context.changectx(repo, rev), copies=copies) | 2071 |
2072 displayer.show(ctx, copies=copies) | |
2073 | |
2077 elif st == 'iter': | 2074 elif st == 'iter': |
2078 if count == limit: break | 2075 if count == limit: break |
2079 if displayer.flush(rev): | 2076 if displayer.flush(rev): |
2080 count += 1 | 2077 count += 1 |
2081 | 2078 |