# HG changeset patch # User Laurent Charignon # Date 1429562358 25200 # Node ID 508f9911b042852c29f89d7cedda975cb1a78a39 # Parent ebcf23fe3032e551a220eade3fe27af7d44c8d93 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. diff -r ebcf23fe3032 -r 508f9911b042 hgext/evolve.py --- 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 diff -r ebcf23fe3032 -r 508f9911b042 hgext/inhibit.py --- 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 """ diff -r ebcf23fe3032 -r 508f9911b042 tests/test-inhibit.t --- 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 |