inhibit: updating to a obsolete commit prints warning message
We move the inhibition marker in the same wlock than the update operation, this
clears the warning message. To make it work we display the warning message on
lock release in evolve.
--- a/hgext/evolve.py Wed Apr 29 15:12:17 2015 -0700
+++ b/hgext/evolve.py Mon Apr 20 13:39:18 2015 -0700
@@ -616,9 +616,16 @@
@eh.wrapcommand("pull")
def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
"""Warn that the working directory parent is an obsolete changeset"""
- res = origfn(ui, repo, *args, **opts)
- if repo['.'].obsolete():
- ui.warn(_('working directory parent is obsolete!\n'))
+ def warnobsolete():
+ if repo['.'].obsolete():
+ ui.warn(_('working directory parent is obsolete!\n'))
+ wlock = None
+ try:
+ wlock = repo.wlock()
+ repo._afterlock(warnobsolete)
+ res = origfn(ui, repo, *args, **opts)
+ finally:
+ lockmod.release(wlock)
return res
# XXX this could wrap transaction code
--- a/hgext/inhibit.py Wed Apr 29 15:12:17 2015 -0700
+++ b/hgext/inhibit.py Mon Apr 20 13:39:18 2015 -0700
@@ -31,6 +31,7 @@
from mercurial import commands
from mercurial import lock as lockmod
from mercurial import bookmarks
+from mercurial import lock as lockmod
from mercurial.i18n import _
cmdtable = {}
@@ -68,10 +69,19 @@
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
+ wlock = None
+ try:
+ # Evolve is running a hook on lock release to display a warning message
+ # if the workind dir's parent is obsolete.
+ # We take the lock here to make sure that we inhibit the parent before
+ # that hook get a chance to run.
+ wlock = repo.wlock()
+ res = orig(ui, repo, *args, **kwargs)
+ newhead = repo['.'].node()
+ _inhibitmarkers(repo, [newhead])
+ return res
+ finally:
+ lockmod.release(wlock)
def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
""" Add inhibition markers to every obsolete bookmarks """
--- a/tests/test-inhibit.t Wed Apr 29 15:12:17 2015 -0700
+++ b/tests/test-inhibit.t Mon Apr 20 13:39:18 2015 -0700
@@ -188,7 +188,6 @@
$ hg update 2 --hidden
2 files updated, 0 files merged, 3 files removed, 0 files unresolved
- working directory parent is obsolete!
$ hg log -G
o 9:55c73a90e4b4 add cJ
|