[PATCH 2 of 2] shelve: acquire lock in the right order

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Apr 13 12:28:36 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1428865171 14400
#      Sun Apr 12 14:59:31 2015 -0400
# Node ID 7d10775076a3ca8ee7d3544112a83483313905c8
# Parent  55c24d69aea7ec2690dee8ff0111112c85d8dfaa
shelve: acquire lock in the right order

Text book says that 'wlock' should be acquired before 'lock'.
Caught through developer warning.

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -542,12 +542,12 @@ def unshelve(ui, repo, *shelved, **opts)
         raise util.Abort(_("shelved change '%s' not found") % basename)
 
     oldquiet = ui.quiet
     wlock = lock = tr = None
     try:
+        wlock = repo.wlock()
         lock = repo.lock()
-        wlock = repo.wlock()
 
         tr = repo.transaction('unshelve', report=lambda x: None)
         oldtiprev = len(repo)
 
         pctx = repo['.']


More information about the Mercurial-devel mailing list