parents: avoid locking the repository during 'hg parents' stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Fri, 06 Nov 2015 18:37:16 -0500
branchstable
changeset 1527 e080d2ae2656
parent 1526 c2a772ade409
child 1528 afb0a33c4f6c
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.
hgext/evolve.py
--- a/hgext/evolve.py	Fri Nov 06 18:02:05 2015 -0500
+++ b/hgext/evolve.py	Fri Nov 06 18:37:16 2015 -0500
@@ -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")