Patchwork [4,of,6] scmutil: rename filecacheentry to filecachesubentry

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 16, 2013, 11:21 p.m.
Message ID <325bd3d4fba6b30a5b50.1384644070@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2999/
State Accepted
Commit 88bd8df008f2aea197d878ea8f49ae5906dc67ab
Headers show

Comments

Siddharth Agarwal - Nov. 16, 2013, 11:21 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1384636746 28800
#      Sat Nov 16 13:19:06 2013 -0800
# Node ID 325bd3d4fba6b30a5b508a4d1d331fe8e8374cb3
# Parent  0e6ce07750ac612a595305e9a60a58b4e0659188
scmutil: rename filecacheentry to filecachesubentry

Upcoming patches will allow the file cache to watch over multiple files, and
call the decorated function again if any of the files change.

The particular use case for this is the bookmark store, which needs to be
invalidated if either .hg/bookmarks or .hg/bookmarks.current changes. (This
doesn't currently happen, which is a bug. This bug will also be fixed in
upcoming patches.)

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -851,14 +851,14 @@ 
               "Mercurial)") % "', '".join(missings))
     return requirements
 
-class filecacheentry(object):
+class filecachesubentry(object):
     def __init__(self, path, stat):
         self.path = path
         self.cachestat = None
         self._cacheable = None
 
         if stat:
-            self.cachestat = filecacheentry.stat(self.path)
+            self.cachestat = filecachesubentry.stat(self.path)
 
             if self.cachestat:
                 self._cacheable = self.cachestat.cacheable()
@@ -868,7 +868,7 @@ 
 
     def refresh(self):
         if self.cacheable():
-            self.cachestat = filecacheentry.stat(self.path)
+            self.cachestat = filecachesubentry.stat(self.path)
 
     def cacheable(self):
         if self._cacheable is not None:
@@ -882,7 +882,7 @@ 
         if not self.cacheable():
             return True
 
-        newstat = filecacheentry.stat(self.path)
+        newstat = filecachesubentry.stat(self.path)
 
         # we may not know if it's cacheable yet, check again now
         if newstat and self._cacheable is None:
@@ -952,7 +952,7 @@ 
 
             # We stat -before- creating the object so our cache doesn't lie if
             # a writer modified between the time we read and stat
-            entry = filecacheentry(path, True)
+            entry = filecachesubentry(path, True)
             entry.obj = self.func(obj)
 
             obj._filecache[self.name] = entry
@@ -964,7 +964,7 @@ 
         if self.name not in obj._filecache:
             # we add an entry for the missing value because X in __dict__
             # implies X in _filecache
-            ce = filecacheentry(self.join(obj, self.path), False)
+            ce = filecachesubentry(self.join(obj, self.path), False)
             obj._filecache[self.name] = ce
         else:
             ce = obj._filecache[self.name]