Patchwork [1,of,2] obsolete: provide a small function to retrieve all mutable revisions

login
register
mail settings
Submitter Pierre-Yves David
Date June 27, 2017, 11:01 a.m.
Message ID <e7f139a172c2075ce887.1498561281@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21767/
State Accepted
Headers show

Comments

Pierre-Yves David - June 27, 2017, 11:01 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1497818291 -7200
#      Sun Jun 18 22:38:11 2017 +0200
# Node ID e7f139a172c2075ce88764938ea4c102ef87935f
# Parent  a49ab7f5e7e765a94a1dfab2ee3b1da695789eb6
# EXP-Topic bettertroubles
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r e7f139a172c2
obsolete: provide a small function to retrieve all mutable revisions

More obsolescence related algorithm focus on the mutable revision. We provide a
tiny utility function to make it easy to access this set.
Yuya Nishihara - June 29, 2017, 1:19 p.m.
On Tue, 27 Jun 2017 13:01:21 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1497818291 -7200
> #      Sun Jun 18 22:38:11 2017 +0200
> # Node ID e7f139a172c2075ce88764938ea4c102ef87935f
> # Parent  a49ab7f5e7e765a94a1dfab2ee3b1da695789eb6
> # EXP-Topic bettertroubles
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r e7f139a172c2
> obsolete: provide a small function to retrieve all mutable revisions

Queued, thanks.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1309,11 +1309,15 @@  def clearobscaches(repo):
     if 'obsstore' in repo._filecache:
         repo.obsstore.caches.clear()
 
+def _mutablerevs(repo):
+    """the set of mutable revision in the repository"""
+    return repo._phasecache.getrevset(repo, (phases.draft, phases.secret))
+
 @cachefor('obsolete')
 def _computeobsoleteset(repo):
     """the set of obsolete revisions"""
     getnode = repo.changelog.node
-    notpublic = repo._phasecache.getrevset(repo, (phases.draft, phases.secret))
+    notpublic = _mutablerevs(repo)
     isobs = repo.obsstore.successors.__contains__
     obs = set(r for r in notpublic if isobs(getnode(r)))
     return obs