comparison mercurial/revset.py @ 25621:21a874693619

revset: refactor the non-public phase code Code for draft and secret are the same. We'll make it more complex to take advantages of the set recomputed in C, so we first refactor the code to only have one place to update (and make sure all behave properly). We do not refactor the 'public()' code because it does not have a natively computed set.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 17 Jun 2015 19:19:57 -0700
parents 5f87f2305ad0
children 85294076adce
comparison
equal deleted inserted replaced
25620:5f87f2305ad0 25621:21a874693619
801 # i18n: "divergent" is a keyword 801 # i18n: "divergent" is a keyword
802 getargs(x, 0, 0, _("divergent takes no arguments")) 802 getargs(x, 0, 0, _("divergent takes no arguments"))
803 divergent = obsmod.getrevs(repo, 'divergent') 803 divergent = obsmod.getrevs(repo, 'divergent')
804 return subset & divergent 804 return subset & divergent
805 805
806 def draft(repo, subset, x):
807 """``draft()``
808 Changeset in draft phase."""
809 # i18n: "draft" is a keyword
810 getargs(x, 0, 0, _("draft takes no arguments"))
811 phase = repo._phasecache.phase
812 target = phases.draft
813 condition = lambda r: phase(repo, r) == target
814 return subset.filter(condition, cache=False)
815
816 def extinct(repo, subset, x): 806 def extinct(repo, subset, x):
817 """``extinct()`` 807 """``extinct()``
818 Obsolete changesets with obsolete descendants only. 808 Obsolete changesets with obsolete descendants only.
819 """ 809 """
820 # i18n: "extinct" is a keyword 810 # i18n: "extinct" is a keyword
1470 for r in getset(repo, fullreposet(repo), x): 1460 for r in getset(repo, fullreposet(repo), x):
1471 ps.update(cl.parentrevs(r)) 1461 ps.update(cl.parentrevs(r))
1472 ps -= set([node.nullrev]) 1462 ps -= set([node.nullrev])
1473 return subset & ps 1463 return subset & ps
1474 1464
1465 def _phase(repo, subset, target):
1466 """helper to select all rev in phase <target>"""
1467 phase = repo._phasecache.phase
1468 condition = lambda r: phase(repo, r) == target
1469 return subset.filter(condition, cache=False)
1470
1471 def draft(repo, subset, x):
1472 """``draft()``
1473 Changeset in draft phase."""
1474 # i18n: "draft" is a keyword
1475 getargs(x, 0, 0, _("draft takes no arguments"))
1476 target = phases.draft
1477 return _phase(repo, subset, target)
1478
1479 def secret(repo, subset, x):
1480 """``secret()``
1481 Changeset in secret phase."""
1482 # i18n: "secret" is a keyword
1483 getargs(x, 0, 0, _("secret takes no arguments"))
1484 target = phases.secret
1485 return _phase(repo, subset, target)
1486
1475 def parentspec(repo, subset, x, n): 1487 def parentspec(repo, subset, x, n):
1476 """``set^0`` 1488 """``set^0``
1477 The set. 1489 The set.
1478 ``set^1`` (or ``set^``), ``set^2`` 1490 ``set^1`` (or ``set^``), ``set^2``
1479 First or second parent, respectively, of all changesets in set. 1491 First or second parent, respectively, of all changesets in set.
1727 """ 1739 """
1728 s = getset(repo, fullreposet(repo), x) 1740 s = getset(repo, fullreposet(repo), x)
1729 subset = subset & s# baseset([r for r in s if r in subset]) 1741 subset = subset & s# baseset([r for r in s if r in subset])
1730 cs = _children(repo, subset, s) 1742 cs = _children(repo, subset, s)
1731 return subset - cs 1743 return subset - cs
1732
1733 def secret(repo, subset, x):
1734 """``secret()``
1735 Changeset in secret phase."""
1736 # i18n: "secret" is a keyword
1737 getargs(x, 0, 0, _("secret takes no arguments"))
1738 phase = repo._phasecache.phase
1739 target = phases.secret
1740 condition = lambda r: phase(repo, r) == target
1741 return subset.filter(condition, cache=False)
1742 1744
1743 def sort(repo, subset, x): 1745 def sort(repo, subset, x):
1744 """``sort(set[, [-]key...])`` 1746 """``sort(set[, [-]key...])``
1745 Sort set by keys. The default sort order is ascending, specify a key 1747 Sort set by keys. The default sort order is ascending, specify a key
1746 as ``-key`` to sort in descending order. 1748 as ``-key`` to sort in descending order.