[PATCH 08 of 12] filecache: allow filecacheentry to be created without stating in __init__

Idan Kamara idankk86 at gmail.com
Mon Dec 17 09:35:33 CST 2012


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1355750671 -7200
# Branch stable
# Node ID 569e314c159920cdaba86d75374e1b6eddb11284
# Parent  92641ad93e4cbb3e570a6630d5ded31db3b1bec3
filecache: allow filecacheentry to be created without stating in __init__

Will be used for properties that are set without getting them first.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -846,14 +846,19 @@
     return requirements
 
 class filecacheentry(object):
-    def __init__(self, path):
+    def __init__(self, path, stat=True):
         self.path = path
-        self.cachestat = filecacheentry.stat(self.path)
 
-        if self.cachestat:
-            self._cacheable = self.cachestat.cacheable()
+        if stat:
+            self.cachestat = filecacheentry.stat(self.path)
+
+            if self.cachestat:
+                self._cacheable = self.cachestat.cacheable()
+            else:
+                # None means we don't know yet
+                self._cacheable = None
         else:
-            # None means we don't know yet
+            self.cachestat = None
             self._cacheable = None
 
     def refresh(self):


More information about the Mercurial-devel mailing list