comparison mercurial/revset.py @ 35339:0c1aff6d73a7

revset: use phasecache.getrevset to calculate public() Other revsets like secret(), draft(), _nonpublic() are using phasescache.getrevset already. The latter is more efficient after D1606. So let's migrate the public() revset function too. Tested using: $ hg debugshell --hidden --cwd hg-committed` In [1]: %timeit len(repo.revs('public()')) * Before D1606: 10 loops, best of 3: 22.5 ms per loop * Before this change, after D1606: 10 loops, best of 3: 28.6 ms per loop * After this change: 10 loops, best of 3: 20.2 ms per loop Therefore `public()` revset becomes even slightly faster after the data structure change by D1606. A similar performance win could also be observed on a large repo. A side effect is `phasecache.getrevset` needs to take a `subset` parameter. That was added with a default value so it won't cause BC issues. Differential Revision: https://phab.mercurial-scm.org/D1620
author Jun Wu <quark@fb.com>
date Fri, 08 Dec 2017 14:20:34 -0800
parents d67bcfc0041f
children 6eee2bcc57c4
comparison
equal deleted inserted replaced
35338:169d66db5920 35339:0c1aff6d73a7
1502 ps -= {node.nullrev} 1502 ps -= {node.nullrev}
1503 return subset & ps 1503 return subset & ps
1504 1504
1505 def _phase(repo, subset, *targets): 1505 def _phase(repo, subset, *targets):
1506 """helper to select all rev in <targets> phases""" 1506 """helper to select all rev in <targets> phases"""
1507 s = repo._phasecache.getrevset(repo, targets) 1507 return repo._phasecache.getrevset(repo, targets, subset)
1508 return subset & s
1509 1508
1510 @predicate('draft()', safe=True) 1509 @predicate('draft()', safe=True)
1511 def draft(repo, subset, x): 1510 def draft(repo, subset, x):
1512 """Changeset in draft phase.""" 1511 """Changeset in draft phase."""
1513 # i18n: "draft" is a keyword 1512 # i18n: "draft" is a keyword
1610 @predicate('public()', safe=True) 1609 @predicate('public()', safe=True)
1611 def public(repo, subset, x): 1610 def public(repo, subset, x):
1612 """Changeset in public phase.""" 1611 """Changeset in public phase."""
1613 # i18n: "public" is a keyword 1612 # i18n: "public" is a keyword
1614 getargs(x, 0, 0, _("public takes no arguments")) 1613 getargs(x, 0, 0, _("public takes no arguments"))
1615 phase = repo._phasecache.phase 1614 return _phase(repo, subset, phases.public)
1616 target = phases.public
1617 condition = lambda r: phase(repo, r) == target
1618 return subset.filter(condition, condrepr=('<phase %r>', target),
1619 cache=False)
1620 1615
1621 @predicate('remote([id [,path]])', safe=False) 1616 @predicate('remote([id [,path]])', safe=False)
1622 def remote(repo, subset, x): 1617 def remote(repo, subset, x):
1623 """Local revision that corresponds to the given identifier in a 1618 """Local revision that corresponds to the given identifier in a
1624 remote repository, if present. Here, the '.' identifier is a 1619 remote repository, if present. Here, the '.' identifier is a