[PATCH 03 of 14] tag: make sure the repository is locked when tagging

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat Jul 1 22:56:28 EDT 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1498952497 -7200
#      Sun Jul 02 01:41:37 2017 +0200
# Node ID 7c6b7f3e14d5b79c80057c356e447911ded68140
# Parent  426a0128cabab5baf44342d6de6869b9d83f4c3e
# EXP-Topic vfs.ward
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 7c6b7f3e14d5
tag: make sure the repository is locked when tagging

Otherwise, writing localtag can happen without the lock.

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -539,9 +539,10 @@ def tag(repo, names, node, message, loca
             raise error.Abort(_('working copy of .hgtags is changed'),
                              hint=_('please commit .hgtags manually'))
 
-    repo.tags() # instantiate the cache
-    _tag(repo.unfiltered(), names, node, message, local, user, date,
-         editor=editor)
+    with repo.wlock():
+        repo.tags() # instantiate the cache
+        _tag(repo.unfiltered(), names, node, message, local, user, date,
+             editor=editor)
 
 def _tag(repo, names, node, message, local, user, date, extra=None,
          editor=False):


More information about the Mercurial-devel mailing list