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

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Aug 15 11:32:11 UTC 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# 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
"hgupdaterepo":

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

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

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/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -696,6 +696,13 @@
         wlock.release()
 
 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)


More information about the Mercurial-devel mailing list