Patchwork [1,of,5] largefiles: put whole "hgupdaterepo" process into the same "wlock" scope

mail settings
Submitter Katsunori FUJIWARA
Date Aug. 15, 2014, 11:32 a.m.
Message ID <0dff07b4d9d070825c83.1408102331@feefifofum>
Download mbox | patch
Permalink /patch/5410/
State Accepted
Headers show


Katsunori FUJIWARA - Aug. 15, 2014, 11:32 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <>
# Date 1408102131 -32400
#      Fri Aug 15 20:28:51 2014 +0900
# Node ID 0dff07b4d9d070825c83b47a672b316aab22bae7
# Parent  2965804483e31210b495f5b3cd498a4e3d3272b0
largefiles: put whole "hgupdaterepo" process into the same "wlock" scope

Before this patch, there are two distinct "wlock" scopes below in

  1. "merge.update" via original "hg.updaterepo" function
  2. "updatelfiles" specific "wlock" scope (to synchronize largefile

In addition to them, "dirstate.walk" is executed between these "wlock"

But these should be executed in the same "wlock" scope for
consistency, because many (indirect) users of "hg.updaterepo" don't
get "wlock" explicitly before invocation of it.

"hg.clean" is invoked without "wlock" from:

  - mqrepo.restore in mq
  - bisect in commands
  - update in commands

"hg.update" is invoked without "wlock" from:

  - clone in mq
  - pullrebase in rebase
  - postincoming in commands (used in "hg pull -u", "hg unbundle")
  - update in commands

This patch puts almost all original "hgupdaterepo" implementation into
"_hgupdaterepo" to reduce changes.


diff --git a/hgext/largefiles/ b/hgext/largefiles/
--- a/hgext/largefiles/
+++ b/hgext/largefiles/
@@ -696,6 +696,13 @@ 
 def hgupdaterepo(orig, repo, node, overwrite):
+    wlock = repo.wlock()
+    try:
+        return _hgupdaterepo(orig, repo, node, overwrite)
+    finally:
+        wlock.release()
+def _hgupdaterepo(orig, repo, node, overwrite):
     if not overwrite:
         # Only call updatelfiles on the standins that have changed to save time
         oldstandins = lfutil.getstandinsstate(repo)