Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 21108:e5ad36a845af
cmdutil: changed _makegraphlogrevset to _makelogrevset
This method will now be used to build both graphlog and log revset after this
series of patches.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Tue, 25 Feb 2014 10:40:04 -0800 |
parents | 1004d3cd65fd |
children | 69402eb72115 |
comparison
equal
deleted
inserted
replaced
21107:4a6c8b6b10d3 | 21108:e5ad36a845af |
---|---|
1455 if stopiteration: | 1455 if stopiteration: |
1456 break | 1456 break |
1457 | 1457 |
1458 return iterate() | 1458 return iterate() |
1459 | 1459 |
1460 def _makegraphfilematcher(repo, pats, followfirst): | 1460 def _makelogfilematcher(repo, pats, followfirst): |
1461 # When displaying a revision with --patch --follow FILE, we have | 1461 # When displaying a revision with --patch --follow FILE, we have |
1462 # to know which file of the revision must be diffed. With | 1462 # to know which file of the revision must be diffed. With |
1463 # --follow, we want the names of the ancestors of FILE in the | 1463 # --follow, we want the names of the ancestors of FILE in the |
1464 # revision, stored in "fcache". "fcache" is populated by | 1464 # revision, stored in "fcache". "fcache" is populated by |
1465 # reproducing the graph traversal already done by --follow revset | 1465 # reproducing the graph traversal already done by --follow revset |
1483 populate() | 1483 populate() |
1484 return scmutil.match(wctx, fcache.get(rev, []), default='path') | 1484 return scmutil.match(wctx, fcache.get(rev, []), default='path') |
1485 | 1485 |
1486 return filematcher | 1486 return filematcher |
1487 | 1487 |
1488 def _makegraphlogrevset(repo, pats, opts, revs): | 1488 def _makelogrevset(repo, pats, opts, revs): |
1489 """Return (expr, filematcher) where expr is a revset string built | 1489 """Return (expr, filematcher) where expr is a revset string built |
1490 from log options and file patterns or None. If --stat or --patch | 1490 from log options and file patterns or None. If --stat or --patch |
1491 are not passed filematcher is None. Otherwise it is a callable | 1491 are not passed filematcher is None. Otherwise it is a callable |
1492 taking a revision number and returning a match objects filtering | 1492 taking a revision number and returning a match objects filtering |
1493 the files to be detailed when displaying the revision. | 1493 the files to be detailed when displaying the revision. |
1594 opts['_patslog'] = list(pats) | 1594 opts['_patslog'] = list(pats) |
1595 | 1595 |
1596 filematcher = None | 1596 filematcher = None |
1597 if opts.get('patch') or opts.get('stat'): | 1597 if opts.get('patch') or opts.get('stat'): |
1598 if follow: | 1598 if follow: |
1599 filematcher = _makegraphfilematcher(repo, pats, followfirst) | 1599 filematcher = _makelogfilematcher(repo, pats, followfirst) |
1600 else: | 1600 else: |
1601 filematcher = lambda rev: match | 1601 filematcher = lambda rev: match |
1602 | 1602 |
1603 expr = [] | 1603 expr = [] |
1604 for op, val in opts.iteritems(): | 1604 for op, val in opts.iteritems(): |
1637 # depends on revisions resolved from --rev... | 1637 # depends on revisions resolved from --rev... |
1638 follow = opts.get('follow') or opts.get('follow_first') | 1638 follow = opts.get('follow') or opts.get('follow_first') |
1639 possiblyunsorted = False # whether revs might need sorting | 1639 possiblyunsorted = False # whether revs might need sorting |
1640 if opts.get('rev'): | 1640 if opts.get('rev'): |
1641 revs = scmutil.revrange(repo, opts['rev']) | 1641 revs = scmutil.revrange(repo, opts['rev']) |
1642 # Don't sort here because _makegraphlogrevset might depend on the | 1642 # Don't sort here because _makelogrevset might depend on the |
1643 # order of revs | 1643 # order of revs |
1644 possiblyunsorted = True | 1644 possiblyunsorted = True |
1645 else: | 1645 else: |
1646 if follow and len(repo) > 0: | 1646 if follow and len(repo) > 0: |
1647 revs = repo.revs('reverse(:.)') | 1647 revs = repo.revs('reverse(:.)') |
1648 else: | 1648 else: |
1649 revs = revset.spanset(repo) | 1649 revs = revset.spanset(repo) |
1650 revs.reverse() | 1650 revs.reverse() |
1651 if not revs: | 1651 if not revs: |
1652 return revset.baseset(), None, None | 1652 return revset.baseset(), None, None |
1653 expr, filematcher = _makegraphlogrevset(repo, pats, opts, revs) | 1653 expr, filematcher = _makelogrevset(repo, pats, opts, revs) |
1654 if possiblyunsorted: | 1654 if possiblyunsorted: |
1655 revs.sort(reverse=True) | 1655 revs.sort(reverse=True) |
1656 if expr: | 1656 if expr: |
1657 # Revset matchers often operate faster on revisions in changelog | 1657 # Revset matchers often operate faster on revisions in changelog |
1658 # order, because most filters deal with the changelog. | 1658 # order, because most filters deal with the changelog. |