# HG changeset patch # User Pierre-Yves David # Date 1425724363 28800 # 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. diff --git a/hgext/inhibit.py b/hgext/inhibit.py --- a/hgext/inhibit.py +++ b/hgext/inhibit.py @@ -51,6 +51,14 @@ 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 @@ -62,7 +70,7 @@ 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: @@ -79,7 +87,7 @@ tr = repo.transaction('obsinhibit') try: repo._obsinhibit -= deinhibited - _schedulewrite(tr, repo._obsinhibit) + _schedulewrite(tr, _filterpublic(repo, repo._obsinhibit)) repo.invalidatevolatilesets() tr.close() finally: diff --git a/tests/test-inhibit.t b/tests/test-inhibit.t --- a/tests/test-inhibit.t +++ b/tests/test-inhibit.t @@ -127,3 +127,49 @@ 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 + +