Show More
@@ -271,15 +271,12 b' def makefilematcher(repo, pats, followfi' | |||||
271 |
|
271 | |||
272 | return filematcher |
|
272 | return filematcher | |
273 |
|
273 | |||
274 | def revset(repo, pats, opts): |
|
274 | def _makelogrevset(repo, pats, opts, revs): | |
275 | """Return (expr, filematcher) where expr is a revset string built |
|
275 | """Return (expr, filematcher) where expr is a revset string built | |
276 |
log options and file patterns |
|
276 | from log options and file patterns or None. If --stat or --patch | |
277 | are ignored when building expr because we do not know if they are |
|
277 | are not passed filematcher is None. Otherwise it is a callable | |
278 | proper revsets or legacy expressions like a 'foo-bar' tags. If |
|
278 | taking a revision number and returning a match objects filtering | |
279 | --stat or --patch are not passed filematcher is None. Otherwise it |
|
279 | the files to be detailed when displaying the revision. | |
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. |
|
|||
283 | """ |
|
280 | """ | |
284 | opt2revset = { |
|
281 | opt2revset = { | |
285 | 'follow': ('follow()', None), |
|
282 | 'follow': ('follow()', None), | |
@@ -298,15 +295,17 b' def revset(repo, pats, opts):' | |||||
298 | } |
|
295 | } | |
299 |
|
296 | |||
300 | opts = dict(opts) |
|
297 | opts = dict(opts) | |
301 | # branch and only_branch are really aliases and must be handled at |
|
298 | # follow or not follow? | |
302 | # the same time |
|
|||
303 | opts['branch'] = opts.get('branch', []) + opts.get('only_branch', []) |
|
|||
304 | follow = opts.get('follow') or opts.get('follow_first') |
|
299 | follow = opts.get('follow') or opts.get('follow_first') | |
305 | followfirst = opts.get('follow_first') |
|
300 | followfirst = opts.get('follow_first') | |
306 | if 'follow' in opts: |
|
301 | if 'follow' in opts: | |
307 | del opts['follow'] |
|
302 | del opts['follow'] | |
308 | if 'follow_first' in opts: |
|
303 | if 'follow_first' in opts: | |
309 | del opts['follow_first'] |
|
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 | # pats/include/exclude are passed to match.match() directly in |
|
309 | # pats/include/exclude are passed to match.match() directly in | |
311 | # _matchfile() revset but walkchangerevs() builds its matcher with |
|
310 | # _matchfile() revset but walkchangerevs() builds its matcher with | |
312 | # scmutil.match(). The difference is input pats are globbed on |
|
311 | # scmutil.match(). The difference is input pats are globbed on | |
@@ -392,6 +391,27 b' def revset(repo, pats, opts):' | |||||
392 | revset = None |
|
391 | revset = None | |
393 | return revset, filematcher |
|
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 | def generate(ui, dag, displayer, showparents, edgefn, getrenamed=None, |
|
415 | def generate(ui, dag, displayer, showparents, edgefn, getrenamed=None, | |
396 | filematcher=None): |
|
416 | filematcher=None): | |
397 | seen, state = [], asciistate() |
|
417 | seen, state = [], asciistate() | |
@@ -434,13 +454,7 b' def graphlog(ui, repo, *pats, **opts):' | |||||
434 |
|
454 | |||
435 | check_unsupported_flags(pats, opts) |
|
455 | check_unsupported_flags(pats, opts) | |
436 |
|
456 | |||
437 |
expr, filematcher = revs |
|
457 | revs, expr, filematcher = getlogrevs(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) |
|
|||
444 | revs = sorted(revs, reverse=1) |
|
458 | revs = sorted(revs, reverse=1) | |
445 | limit = cmdutil.loglimit(opts) |
|
459 | limit = cmdutil.loglimit(opts) | |
446 | if limit is not None: |
|
460 | if limit is not None: |
@@ -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.revs |
|
93 | > expr = graphlog.getlogrevs(repo, pats, opts)[1] | |
94 | > if expr: |
|
94 | > if expr: | |
95 | > tree = revset.parse(expr)[0] |
|
95 | > tree = revset.parse(expr)[0] | |
96 | > else: |
|
96 | > else: | |
@@ -1461,12 +1461,7 b' glog always reorders nodes which explain' | |||||
1461 | ('symbol', 'user') |
|
1461 | ('symbol', 'user') | |
1462 | ('string', 'not-a-user'))))) |
|
1462 | ('string', 'not-a-user'))))) | |
1463 | $ testlog -b not-a-branch |
|
1463 | $ testlog -b not-a-branch | |
1464 | [] |
|
1464 | abort: unknown revision 'not-a-branch'! | |
1465 | (group |
|
|||
1466 | (group |
|
|||
1467 | (func |
|
|||
1468 | ('symbol', 'branch') |
|
|||
1469 | ('string', 'not-a-branch')))) |
|
|||
1470 | abort: unknown revision 'not-a-branch'! |
|
1465 | abort: unknown revision 'not-a-branch'! | |
1471 | abort: unknown revision 'not-a-branch'! |
|
1466 | abort: unknown revision 'not-a-branch'! | |
1472 | $ testlog -b default -b branch --only-branch branch |
|
1467 | $ testlog -b default -b branch --only-branch branch |
General Comments 0
You need to be logged in to leave comments.
Login now