##// END OF EJS Templates
graphlog: refactor revset() to return revisions...
Patrick Mezard -
r16405:17deb6bb default
parent child Browse files
Show More
@@ -271,15 +271,12 b' def makefilematcher(repo, pats, followfi'
271 271
272 272 return filematcher
273 273
274 def revset(repo, pats, opts):
274 def _makelogrevset(repo, pats, opts, revs):
275 275 """Return (expr, filematcher) where expr is a revset string built
276 log options and file patterns, or None. Note that --rev options
277 are ignored when building expr because we do not know if they are
278 proper revsets or legacy expressions like a 'foo-bar' tags. If
279 --stat or --patch are not passed filematcher is None. Otherwise it
280 a a callable taking a revision number and returning a match
281 objects filtering the files to be detailed when displaying the
282 revision.
276 from log options and file patterns or None. If --stat or --patch
277 are not passed filematcher is None. Otherwise it is a callable
278 taking a revision number and returning a match objects filtering
279 the files to be detailed when displaying the revision.
283 280 """
284 281 opt2revset = {
285 282 'follow': ('follow()', None),
@@ -298,15 +295,17 b' def revset(repo, pats, opts):'
298 295 }
299 296
300 297 opts = dict(opts)
301 # branch and only_branch are really aliases and must be handled at
302 # the same time
303 opts['branch'] = opts.get('branch', []) + opts.get('only_branch', [])
298 # follow or not follow?
304 299 follow = opts.get('follow') or opts.get('follow_first')
305 300 followfirst = opts.get('follow_first')
306 301 if 'follow' in opts:
307 302 del opts['follow']
308 303 if 'follow_first' in opts:
309 304 del opts['follow_first']
305
306 # branch and only_branch are really aliases and must be handled at
307 # the same time
308 opts['branch'] = opts.get('branch', []) + opts.get('only_branch', [])
310 309 # pats/include/exclude are passed to match.match() directly in
311 310 # _matchfile() revset but walkchangerevs() builds its matcher with
312 311 # scmutil.match(). The difference is input pats are globbed on
@@ -392,6 +391,27 b' def revset(repo, pats, opts):'
392 391 revset = None
393 392 return revset, filematcher
394 393
394 def getlogrevs(repo, pats, opts):
395 """Return (revs, expr, filematcher) where revs is a list of
396 revision numbers, expr is a revset string built from log options
397 and file patterns or None, and used to filter 'revs'. If --stat or
398 --patch are not passed filematcher is None. Otherwise it is a
399 callable taking a revision number and returning a match objects
400 filtering the files to be detailed when displaying the revision.
401 """
402 if not len(repo):
403 return [], None, None
404 if opts.get('rev'):
405 revs = scmutil.revrange(repo, opts['rev'])
406 else:
407 revs = range(len(repo))
408 if not revs:
409 return [], None, None
410 expr, filematcher = _makelogrevset(repo, pats, opts, revs)
411 if expr:
412 revs = revsetmod.match(repo.ui, expr)(repo, revs)
413 return revs, expr, filematcher
414
395 415 def generate(ui, dag, displayer, showparents, edgefn, getrenamed=None,
396 416 filematcher=None):
397 417 seen, state = [], asciistate()
@@ -434,13 +454,7 b' def graphlog(ui, repo, *pats, **opts):'
434 454
435 455 check_unsupported_flags(pats, opts)
436 456
437 expr, filematcher = revset(repo, pats, opts)
438 if opts.get('rev'):
439 revs = scmutil.revrange(repo, opts['rev'])
440 else:
441 revs = range(len(repo))
442 if expr:
443 revs = revsetmod.match(repo.ui, expr)(repo, revs)
457 revs, expr, filematcher = getlogrevs(repo, pats, opts)
444 458 revs = sorted(revs, reverse=1)
445 459 limit = cmdutil.loglimit(opts)
446 460 if limit is not None:
@@ -90,7 +90,7 b' o (0) root'
90 90 > def uisetup(ui):
91 91 > def printrevset(orig, ui, repo, *pats, **opts):
92 92 > if opts.get('print_revset'):
93 > expr = graphlog.revset(repo, pats, opts)[0]
93 > expr = graphlog.getlogrevs(repo, pats, opts)[1]
94 94 > if expr:
95 95 > tree = revset.parse(expr)[0]
96 96 > else:
@@ -1461,12 +1461,7 b' glog always reorders nodes which explain'
1461 1461 ('symbol', 'user')
1462 1462 ('string', 'not-a-user')))))
1463 1463 $ testlog -b not-a-branch
1464 []
1465 (group
1466 (group
1467 (func
1468 ('symbol', 'branch')
1469 ('string', 'not-a-branch'))))
1464 abort: unknown revision 'not-a-branch'!
1470 1465 abort: unknown revision 'not-a-branch'!
1471 1466 abort: unknown revision 'not-a-branch'!
1472 1467 $ testlog -b default -b branch --only-branch branch
General Comments 0
You need to be logged in to leave comments. Login now