changeset 27196:7b4a61570d61

gpg: make sign acquire wlock before processing Before this patch, "hg sign" of gpg extension executes/evaluates below without acquisition of wlock. - repo.dirstate.parents() - '.hgsigs' not in repo.dirstate It may cause unintentional result, if another command runs parallelly (see also issue4368). To avoid this issue, this patch makes "hg sign" of gpg extension acquire wlock before processing.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 02 Dec 2015 03:12:08 +0900
parents 84de71ec5c61
children 6df3ec5bb813
files hgext/gpg.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/gpg.py	Wed Dec 02 03:12:08 2015 +0900
+++ b/hgext/gpg.py	Wed Dec 02 03:12:08 2015 +0900
@@ -9,6 +9,7 @@
 from mercurial import util, commands, match, cmdutil, error
 from mercurial import node as hgnode
 from mercurial.i18n import _
+from mercurial import lock as lockmod
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -222,7 +223,14 @@
 
     See :hg:`help dates` for a list of formats valid for -d/--date.
     """
+    wlock = None
+    try:
+        wlock = repo.wlock()
+        return _dosign(ui, repo, *revs, **opts)
+    finally:
+        lockmod.release(wlock)
 
+def _dosign(ui, repo, *revs, **opts):
     mygpg = newgpg(ui, **opts)
     sigver = "0"
     sigmessage = ""