Patchwork D10851: vfs: add a `register_file` method on the vfs class

login
register
mail settings
Submitter phabricator
Date June 9, 2021, 2:38 p.m.
Message ID <differential-rev-PHID-DREV-emozl4k62vb6365idau5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49170/
State Superseded
Headers show

Comments

phabricator - June 9, 2021, 2:38 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is used by the fncache vfs to register new file. Until now, `fncache` have
  been doing this "automatically" by monitoring write pattern. However this is
  fragile and when we copy files in place by other means, we need something more
  robuts. So we add an explicit method to do so.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/store.py
  mercurial/vfs.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -329,6 +329,9 @@ 
                     None  # pytype: disable=attribute-error
                 )
 
+    def register_file(self, path):
+        """generic hook point to lets fncache steer its stew"""
+
 
 class vfs(abstractvfs):
     """Operate files relative to a base directory
diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -730,6 +730,11 @@ 
         else:
             return self.vfs.join(path)
 
+    def register_file(self, path):
+        """generic hook point to lets fncache steer its stew"""
+        if path.startswith(b'data/') or path.startswith(b'meta/'):
+            self.fncache.add(path)
+
 
 class fncachestore(basicstore):
     def __init__(self, path, vfstype, dotencode):