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

login
register
mail settings
Submitter Pierre-Yves David
Date July 2, 2017, 2:56 a.m.
Message ID <7c6b7f3e14d5b79c8005.1498964188@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21881/
State Accepted
Headers show

Comments

Pierre-Yves David - July 2, 2017, 2:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.

Patch

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):