##// END OF EJS Templates
merge changes from mpm
Dirkjan Ochtman -
r9667:8743f2e1 merge default
parent child Browse files
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 continue
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 continue
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(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()
@@ -1022,24 +1022,26 b' def show_changeset(ui, repo, opts, buffe'
1022
1022
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
1025 df = util.matchdate(date)
1026 df = util.matchdate(date)
1026 m = matchall(repo)
1027 m = matchall(repo)
1027 results = {}
1028 results = {}
1028 for st, ctx, fns in walkchangerevs(ui, repo, m, {'rev': None}):
1029
1030 def prep(ctx, fns):
1031 d = ctx.date()
1032 if df(d[0]):
1033 results[rev] = d
1034
1035 for ctx in walkchangerevs(repo, m, {'rev': None}, prep):
1029 rev = ctx.rev()
1036 rev = ctx.rev()
1030 if st == 'add':
1037 if rev in results:
1031 d = ctx.date()
1038 ui.status(_("Found revision %s from %s\n") %
1032 if df(d[0]):
1039 (rev, util.datestr(results[rev])))
1033 results[rev] = d
1040 return str(rev)
1034 elif st == 'iter':
1035 if rev in results:
1036 ui.status(_("Found revision %s from %s\n") %
1037 (rev, util.datestr(results[rev])))
1038 return str(rev)
1039
1041
1040 raise util.Abort(_("revision matching date not found"))
1042 raise util.Abort(_("revision matching date not found"))
1041
1043
1042 def walkchangerevs(ui, repo, match, opts):
1044 def walkchangerevs(repo, match, opts, prepare):
1043 '''Iterate over files and the revs in which they changed.
1045 '''Iterate over files and the revs in which they changed.
1044
1046
1045 Callers most commonly need to iterate backwards over the history
1047 Callers most commonly need to iterate backwards over the history
@@ -1050,15 +1052,9 b' def walkchangerevs(ui, repo, match, opts'
1050 window, we first walk forwards to gather data, then in the desired
1052 window, we first walk forwards to gather data, then in the desired
1051 order (usually backwards) to display it.
1053 order (usually backwards) to display it.
1052
1054
1053 This function returns an iterator. The iterator yields 3-tuples.
1055 This function returns an iterator yielding contexts. Before
1054 They will be of one of the following forms:
1056 yielding each context, the iterator will first call the prepare
1055
1057 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
1058
1063 def increasing_windows(start, end, windowsize=8, sizelimit=512):
1059 def increasing_windows(start, end, windowsize=8, sizelimit=512):
1064 if start < end:
1060 if start < end:
@@ -1093,6 +1089,7 b' def walkchangerevs(ui, repo, match, opts'
1093 # No files, no patterns. Display all revs.
1089 # No files, no patterns. Display all revs.
1094 wanted = set(revs)
1090 wanted = set(revs)
1095 copies = []
1091 copies = []
1092
1096 if not slowpath:
1093 if not slowpath:
1097 # Only files, no patterns. Check the history of each file.
1094 # Only files, no patterns. Check the history of each file.
1098 def filerevgen(filelog, node):
1095 def filerevgen(filelog, node):
@@ -1129,8 +1126,6 b' def walkchangerevs(ui, repo, match, opts'
1129 slowpath = True
1126 slowpath = True
1130 break
1127 break
1131 else:
1128 else:
1132 ui.warn(_('%s:%s copy source revision cannot be found!\n')
1133 % (file_, short(node)))
1134 continue
1129 continue
1135 for rev, copied in filerevgen(filelog, node):
1130 for rev, copied in filerevgen(filelog, node):
1136 if rev <= maxrev:
1131 if rev <= maxrev:
@@ -1215,6 +1210,7 b' def walkchangerevs(ui, repo, match, opts'
1215 return rev in wanted
1210 return rev in wanted
1216
1211
1217 for i, window in increasing_windows(0, len(revs)):
1212 for i, window in increasing_windows(0, len(revs)):
1213 change = util.cachefunc(repo.changectx)
1218 nrevs = [rev for rev in revs[i:i+window] if want(rev)]
1214 nrevs = [rev for rev in revs[i:i+window] if want(rev)]
1219 for rev in sorted(nrevs):
1215 for rev in sorted(nrevs):
1220 fns = fncache.get(rev)
1216 fns = fncache.get(rev)
@@ -1225,9 +1221,9 b' def walkchangerevs(ui, repo, match, opts'
1225 if match(f):
1221 if match(f):
1226 yield f
1222 yield f
1227 fns = fns_generator()
1223 fns = fns_generator()
1228 yield 'add', ctx, fns
1224 prepare(ctx, fns)
1229 for rev in nrevs:
1225 for rev in nrevs:
1230 yield 'iter', change(rev), None
1226 yield change(rev)
1231 return iterate()
1227 return iterate()
1232
1228
1233 def commit(ui, repo, commitfunc, pats, opts):
1229 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 rev = ctx.rev()
1307 rev = ctx.rev()
1308 pctx = ctx.parents()[0]
1308 pctx = ctx.parents()[0]
1309 parent = pctx.rev()
1309 parent = pctx.rev()
1310 matches.setdefault(rev, {})
1310 matches.setdefault(rev, {})
1311 matches.setdefault(parent, {})
1311 matches.setdefault(parent, {})
1312 files = revfiles.setdefault(rev, [])
1312 files = revfiles.setdefault(rev, [])
1313 for fn in fns:
1313 for fn in fns:
1314 flog = getfile(fn)
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 continue
1339 pass
1319
1340
1320 copied = flog.renamed(fnode)
1341 for ctx in cmdutil.walkchangerevs(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 if fn in skip:
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
@@ -2034,53 +2035,42 b' def log(ui, repo, *pats, **opts):'
2034 if opts["date"]:
2035 if opts["date"]:
2035 df = util.matchdate(opts["date"])
2036 df = util.matchdate(opts["date"])
2036
2037
2037 only_branches = opts.get('only_branch')
2038
2039 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
2038 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
2040 for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, opts):
2039 def prep(ctx, fns):
2041 rev = ctx.rev()
2040 rev = ctx.rev()
2042 if st == 'add':
2041 parents = [p for p in repo.changelog.parentrevs(rev)
2043 parents = [p for p in repo.changelog.parentrevs(rev)
2042 if p != nullrev]
2044 if p != nullrev]
2043 if opts.get('no_merges') and len(parents) == 2:
2045 if opts.get('no_merges') and len(parents) == 2:
2044 return
2046 continue
2045 if opts.get('only_merges') and len(parents) != 2:
2047 if opts.get('only_merges') and len(parents) != 2:
2046 return
2048 continue
2047 if opts.get('only_branch') and ctx.branch() not in opts['only_branch']:
2049
2048 return
2050 if only_branches and ctx.branch() not in only_branches:
2049 if df and not df(ctx.date()[0]):
2051 continue
2050 return
2052
2051 if opts['user'] and not [k for k in opts['user'] if k in ctx.user()]:
2053 if df and not df(ctx.date()[0]):
2052 return
2054 continue
2053 if opts.get('keyword'):
2055
2054 for k in [kw.lower() for kw in opts['keyword']]:
2056 if opts.get('keyword'):
2055 if (k in ctx.user().lower() or
2057 miss = 0
2056 k in ctx.description().lower() or
2058 for k in [kw.lower() for kw in opts['keyword']]:
2057 k in " ".join(ctx.files()).lower()):
2059 if not (k in ctx.user().lower() or
2058 break
2060 k in ctx.description().lower() or
2059 else:
2061 k in " ".join(ctx.files()).lower()):
2060 return
2062 miss = 1
2061
2063 break
2062 copies = []
2064 if miss:
2063 if opts.get('copies') and rev:
2065 continue
2064 for fn in ctx.files():
2066
2065 rename = getrenamed(fn, rev)
2067 if opts['user']:
2066 if rename:
2068 if not [k for k in opts['user'] if k in ctx.user()]:
2067 copies.append((fn, rename[0]))
2069 continue
2068
2070
2069 displayer.show(ctx, copies=copies)
2071 copies = []
2070
2072 if opts.get('copies') and rev:
2071 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2073 for fn in ctx.files():
2072 if count != limit:
2074 rename = getrenamed(fn, rev)
2073 if displayer.flush(ctx.rev()):
2075 if rename:
2076 copies.append((fn, rename[0]))
2077
2078 displayer.show(ctx, copies=copies)
2079
2080 elif st == 'iter':
2081 if count == limit: break
2082
2083 if displayer.flush(rev):
2084 count += 1
2074 count += 1
2085
2075
2086 def manifest(ui, repo, node=None, rev=None):
2076 def manifest(ui, repo, node=None, rev=None):
General Comments 0
You need to be logged in to leave comments. Login now