changeset 1618:e080d2ae2656 stable

parents: avoid locking the repository during 'hg parents' The wrapping code was initially written for update and pull who need the lock anyway. We duplicated the logic in the parent case to remove the need for locking.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 06 Nov 2015 18:37:16 -0500
parents c2a772ade409
children afb0a33c4f6c
files hgext/evolve.py
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -678,16 +678,19 @@
 
 # This section take care of issue warning to the user when troubles appear
 
+
+def _warnobsoletewc(ui, repo):
+    if repo['.'].obsolete():
+        ui.warn(_('working directory parent is obsolete!\n'))
+        if (not ui.quiet) and obsolete.isenabled(repo, commandopt):
+            ui.warn(_('(use "hg evolve" to update to its successor)\n'))
+
 @eh.wrapcommand("update")
-@eh.wrapcommand("parents")
 @eh.wrapcommand("pull")
 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
     """Warn that the working directory parent is an obsolete changeset"""
     def warnobsolete():
-        if repo['.'].obsolete():
-            ui.warn(_('working directory parent is obsolete!\n'))
-            if (not ui.quiet) and obsolete.isenabled(repo, commandopt):
-                ui.warn(_('(use "hg evolve" to update to its successor)\n'))
+        _warnobsoletewc(ui, repo)
     wlock = None
     try:
         wlock = repo.wlock()
@@ -697,6 +700,12 @@
         lockmod.release(wlock)
     return res
 
+@eh.wrapcommand("parents")
+def wrapparents(origfn, ui, repo, *args, **opts):
+    res = origfn(ui, repo, *args, **opts)
+    _warnobsoletewc(ui, repo)
+    return res
+
 # XXX this could wrap transaction code
 # XXX (but this is a bit a layer violation)
 @eh.wrapcommand("commit")