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

login
register
mail settings
Submitter Idan Kamara
Date Dec. 17, 2012, 3:35 p.m.
Message ID <569e314c159920cdaba8.1355758533@idan>
Download mbox | patch
Permalink /patch/162/
State Superseded, archived
Commit 216230643ae2a503c9c346b92c3d9276bd3fb36b
Headers show

Comments

Idan Kamara - Dec. 17, 2012, 3:35 p.m.
# 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.

Patch

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):