Patchwork [4,of,6] hg: acquire wlock while updating the working directory via updatetotally

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 11, 2016, 7:41 p.m.
Message ID <231ea15298afd3e1a434.1457725269@feefifofum>
Download mbox | patch
Permalink /patch/13814/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - March 11, 2016, 7:41 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1457724942 -32400
#      Sat Mar 12 04:35:42 2016 +0900
# Node ID 231ea15298afd3e1a4347791d4eb904742bf8243
# Parent  bea5e68aafac6a1f2ce960ff13a9512f8349dd7e
hg: acquire wlock while updating the working directory via updatetotally

updatetotally() might be invoked outside wlock scope (e.g. invocation
via postincoming() at "hg unbundle" or "hg pull").

In such case, acquisition of wlock is needed for consistent view,
because parallel "hg update" and/or "hg bookmarks" might change
working directory status while executing updatetotally().

Strictly speaking, truly consistent updating should acquire also store
lock, because active bookmark might be moved to another one outside
wlock scope (e.g. pulling from other repository causes updating
current active one).

Acquisition of wlock in this patch ensures consistency in as same
level as past "hg update".

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -714,7 +714,7 @@  def updatetotally(ui, repo, checkout, br
 
     This returns whether conflict is detected at updating or not.
     """
-    if True:
+    with repo.wlock():
         movemarkfrom = None
         warndest = False
         if checkout is None: