Patchwork D8952: remotefilelog: acquire lock before writing requirements on clone

login
register
mail settings
Submitter phabricator
Date Aug. 26, 2020, 10:05 a.m.
Message ID <differential-rev-PHID-DREV-lmrkaxgbpqm36s3ttykr-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47052/
State Superseded
Headers show

Comments

phabricator - Aug. 26, 2020, 10:05 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Performing a shallow clone in remotefilelog does not acquire lock. This leads to
  following warning when we try to write some requirements in store:
  
    --- /home/gps/src/hg-committed/tests/test-remotefilelog-share.t
    +++ /home/gps/src/hg-committed/tests/test-remotefilelog-share.t#safe.err
    @@ -28,6 +28,7 @@
    
    
       $ hgcloneshallow ssh://user@dummy/master source --noupdate -q
    +  devel-warn: write with no lock: "requires" at: /home/gps/src/hg-committed/mercurial/scmutil.py:1505 (writerequires)
       $ hg share source dest
       updating working directory
       1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  
  Let's lock before writing the requirements file.
  
  Another solution which I can think of is not warn about missing lock when
  writing to requires file in store.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8952

AFFECTED FILES
  hgext/remotefilelog/__init__.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -362,7 +362,10 @@ 
                         self.unfiltered().__class__,
                     )
                 self.requirements.add(constants.SHALLOWREPO_REQUIREMENT)
-                scmutil.writereporequirements(self)
+                with self.lock():
+                    # acquire store lock before writing requirements as some
+                    # requirements might be written to .hg/store/requires
+                    scmutil.writereporequirements(self)
 
                 # Since setupclient hadn't been called, exchange.pull was not
                 # wrapped. So we need to manually invoke our version of it.