Patchwork [2,of,6,evolve-ext,for-the-record] inhibit: Add some inhibition clearing mechanism

login
register
mail settings
Submitter Pierre-Yves David
Date April 1, 2015, 11:50 p.m.
Message ID <577f5340be6fe391cd5b.1427932209@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8432/
State Accepted
Headers show

Comments

Pierre-Yves David - April 1, 2015, 11:50 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1425724363 28800
#      Sat Mar 07 02:32:43 2015 -0800
# Node ID 577f5340be6fe391cd5b490e459e3688f0efd0a3
# Parent  859a854cedc3557922978415708ad6ce2e5ab785
inhibit: Add some inhibition clearing mechanism

We do not want to keep inhibition marker around for ever. So we are removing the
one applying on public changeset.

Patch

diff --git a/hgext/inhibit.py b/hgext/inhibit.py
--- a/hgext/inhibit.py
+++ b/hgext/inhibit.py
@@ -49,10 +49,18 @@  def _schedulewrite(tr, obsinhibit):
         raw = ''.join(obsinhibit)
         fp.write(raw)
     tr.addfilegenerator('obsinhibit', ('obsinhibit',), writer)
     tr.hookargs['obs_inbihited'] = '1'
 
+def _filterpublic(repo, nodes):
+    """filter out inhibitor on public changeset
+
+    Public changesets are already immune to obsolescence"""
+    getrev = repo.changelog.nodemap.get
+    getphase = repo._phasecache.phase
+    return (n for n in repo._obsinhibit if getphase(repo, getrev(n)))
+
 def _inhibitmarkers(repo, nodes):
     """add marker inhibitor for all obsolete revision under <nodes>
 
     Content of <nodes> and all mutable ancestors are considered. Marker for
     obsolete revision only are created.
@@ -60,11 +68,11 @@  def _inhibitmarkers(repo, nodes):
     newinhibit = repo.set('::%ln and obsolete()', nodes)
     if newinhibit:
         tr = repo.transaction('obsinhibit')
         try:
             repo._obsinhibit.update(c.node() for c in newinhibit)
-            _schedulewrite(tr, repo._obsinhibit)
+            _schedulewrite(tr, _filterpublic(repo, repo._obsinhibit))
             repo.invalidatevolatilesets()
             tr.close()
         finally:
             tr.release()
 
@@ -77,11 +85,11 @@  def _deinhibitmarkers(repo, nodes):
     deinhibited = repo._obsinhibit & set(nodes)
     if deinhibited:
         tr = repo.transaction('obsinhibit')
         try:
             repo._obsinhibit -= deinhibited
-            _schedulewrite(tr, repo._obsinhibit)
+            _schedulewrite(tr, _filterpublic(repo, repo._obsinhibit))
             repo.invalidatevolatilesets()
             tr.close()
         finally:
             tr.release()
 
diff --git a/tests/test-inhibit.t b/tests/test-inhibit.t
--- a/tests/test-inhibit.t
+++ b/tests/test-inhibit.t
@@ -125,5 +125,51 @@  and no divergence
   parent: 9:55c73a90e4b4 tip
    add cJ
   branch: default
   commit: (clean)
   update: 1 new changesets, 2 branch heads (merge)
+
+check public revision got cleared
+(when adding the second inhibitor, the first one is removed because it is public)
+
+  $ wc -m .hg/store/obsinhibit
+  20 .hg/store/obsinhibit
+  $ hg prune 7
+  1 changesets pruned
+  $ hg debugobsinhibit --hidden 18214586bf78
+  $ wc -m .hg/store/obsinhibit
+  20 .hg/store/obsinhibit
+  $ hg log -G
+  @  9:55c73a90e4b4 add cJ
+  |
+  | o  7:18214586bf78 add cJ
+  |/
+  o  6:cf5c4f4554ce add cH
+  |
+  o  5:5419eb264a33 add cG
+  |
+  o  4:98065434e5c6 add cE
+  |
+  o  0:54ccbc537fc2 add cA
+  
+  $ hg phase --public 7
+  $ hg prune 9
+  1 changesets pruned
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  working directory now at cf5c4f4554ce
+  $ hg debugobsinhibit --hidden 55c73a90e4b4
+  $ wc -m .hg/store/obsinhibit
+  20 .hg/store/obsinhibit
+  $ hg log -G
+  o  9:55c73a90e4b4 add cJ
+  |
+  | o  7:18214586bf78 add cJ
+  |/
+  @  6:cf5c4f4554ce add cH
+  |
+  o  5:5419eb264a33 add cG
+  |
+  o  4:98065434e5c6 add cE
+  |
+  o  0:54ccbc537fc2 add cA
+  
+