hgext/inhibit.py
changeset 1233 63ee05dd557a
parent 1232 37c00aeb4762
child 1234 c15d4677f2ba
--- a/hgext/inhibit.py	Fri Mar 27 10:58:04 2015 -0700
+++ b/hgext/inhibit.py	Mon Mar 30 11:45:17 2015 -0700
@@ -28,6 +28,7 @@
 from mercurial import repoview
 from mercurial import revset
 from mercurial import error
+from mercurial import commands
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -48,6 +49,19 @@
     repo.__class__ = obsinhibitedrepo
     repo._explicitaccess = set()
 
+
+def _update(orig, ui, repo, *args, **kwargs):
+    """
+    When moving to a commit we want to inhibit any obsolete commit affecting
+    the changeset we are updating to. In other words we don't want any visible
+    commit to be obsolete.
+    """
+    res = orig(ui, repo, *args, **kwargs)
+    newhead = repo['.'].node()
+    _inhibitmarkers(repo, [newhead])
+    return res
+
+
 # obsolescence inhibitor
 ########################
 
@@ -137,6 +151,9 @@
     extensions.wrapfunction(obsolete, 'createmarkers', _createmarkers)
     extensions.wrapfunction(repoview, '_getdynamicblockers', _accessvisible)
     extensions.wrapfunction(revset, 'posttreebuilthook', _posttreebuilthook)
+    # wrap update to make sure that no obsolete commit is visible after an
+    # update
+    extensions.wrapcommand(commands.table, 'update', _update)
 
 def gethashsymbols(tree):
     # Returns the list of symbols of the tree that look like hashes