##// END OF EJS Templates
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard -
r16160:1bfc7ba8 default
parent child Browse files
Show More
@@ -245,7 +245,7 b' def check_unsupported_flags(pats, opts):'
245 raise util.Abort(_("-G/--graph option is incompatible with --follow "
245 raise util.Abort(_("-G/--graph option is incompatible with --follow "
246 "with file argument"))
246 "with file argument"))
247
247
248 def revset(pats, opts):
248 def revset(repo, pats, opts):
249 """Return revset str built of revisions, log options and file patterns.
249 """Return revset str built of revisions, log options and file patterns.
250 """
250 """
251 opt2revset = {
251 opt2revset = {
@@ -258,6 +258,7 b' def revset(pats, opts):'
258 'exclude': ('not file(%(val)r)', ' and '),
258 'exclude': ('not file(%(val)r)', ' and '),
259 'include': ('file(%(val)r)', ' and '),
259 'include': ('file(%(val)r)', ' and '),
260 '_pats': ('file(%(val)r)', ' or '),
260 '_pats': ('file(%(val)r)', ' or '),
261 '_patslog': ('filelog(%(val)r)', ' or '),
261 'keyword': ('keyword(%(val)r)', ' or '),
262 'keyword': ('keyword(%(val)r)', ' or '),
262 'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '),
263 'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '),
263 'user': ('user(%(val)r)', ' or '),
264 'user': ('user(%(val)r)', ' or '),
@@ -269,7 +270,21 b' def revset(pats, opts):'
269 # the same time
270 # the same time
270 if 'branch' in opts and 'only_branch' in opts:
271 if 'branch' in opts and 'only_branch' in opts:
271 opts['branch'] = opts['branch'] + opts.pop('only_branch')
272 opts['branch'] = opts['branch'] + opts.pop('only_branch')
272 opts['_pats'] = list(pats)
273
274 match = scmutil.match(repo[None], pats, opts)
275 slowpath = match.anypats() or (match.files() and opts.get('removed'))
276 if not slowpath:
277 for f in match.files():
278 filelog = repo.file(f)
279 if not len(filelog):
280 # A zero count may be a directory or deleted file, so
281 # try to find matching entries on the slow path.
282 slowpath = True
283 if slowpath:
284 # See cmdutil.walkchangerevs() slow path
285 opts['_pats'] = list(pats)
286 else:
287 opts['_patslog'] = list(pats)
273
288
274 revset = []
289 revset = []
275 for op, val in opts.iteritems():
290 for op, val in opts.iteritems():
@@ -324,7 +339,7 b' def graphlog(ui, repo, *pats, **opts):'
324
339
325 check_unsupported_flags(pats, opts)
340 check_unsupported_flags(pats, opts)
326
341
327 revs = sorted(scmutil.revrange(repo, [revset(pats, opts)]), reverse=1)
342 revs = sorted(scmutil.revrange(repo, [revset(repo, pats, opts)]), reverse=1)
328 limit = cmdutil.loglimit(opts)
343 limit = cmdutil.loglimit(opts)
329 if limit is not None:
344 if limit is not None:
330 revs = revs[:limit]
345 revs = revs[:limit]
@@ -90,7 +90,7 b' o (0) root'
90 > def uisetup(ui):
90 > def uisetup(ui):
91 > def printrevset(orig, ui, repo, *pats, **opts):
91 > def printrevset(orig, ui, repo, *pats, **opts):
92 > if opts.get('print_revset'):
92 > if opts.get('print_revset'):
93 > expr = graphlog.revset(pats, opts)
93 > expr = graphlog.revset(repo, pats, opts)
94 > tree = revset.parse(expr)[0]
94 > tree = revset.parse(expr)[0]
95 > ui.write(tree, "\n")
95 > ui.write(tree, "\n")
96 > return 0
96 > return 0
@@ -1519,5 +1519,12 b' Dedicated repo for --follow and paths fi'
1519 o (0) add a
1519 o (0) add a
1520
1520
1521
1521
1522 $ testlog a
1523 ('group', ('group', ('func', ('symbol', 'filelog'), ('string', 'a'))))
1524 $ testlog a b
1525 ('group', ('group', ('or', ('func', ('symbol', 'filelog'), ('string', 'a')), ('func', ('symbol', 'filelog'), ('string', 'b')))))
1526
1527 Test falling back to slow path for non-existing files
1528
1522 $ testlog a c
1529 $ testlog a c
1523 ('group', ('group', ('or', ('func', ('symbol', 'file'), ('string', 'a')), ('func', ('symbol', 'file'), ('string', 'c')))))
1530 ('group', ('group', ('or', ('func', ('symbol', 'file'), ('string', 'a')), ('func', ('symbol', 'file'), ('string', 'c')))))
General Comments 0
You need to be logged in to leave comments. Login now