Patchwork [07,of,10,v2] filecache: allow filecacheentry to be created without stating in __init__

login
register
mail settings
Submitter Idan Kamara
Date Jan. 10, 2013, 10:10 p.m.
Message ID <800bb48683efd990824c.1357855854@idan>
Download mbox | patch
Permalink /patch/531/
State Accepted
Commit 216230643ae2a503c9c346b92c3d9276bd3fb36b
Delegated to: Kevin Bullock
Headers show

Comments

Idan Kamara - Jan. 10, 2013, 10:10 p.m.
# HG changeset patch
# User Idan Kamara <idankk86@gmail.com>
# Date 1357854893 -7200
# Node ID 800bb48683efd990824c8988da2c4f4da303ce55
# Parent  de68b1d50d554b7e20ef87465d497390444e3535
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
@@ -863,15 +863,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)
+        self.cachestat = None
+        self._cacheable = None
 
-        if self.cachestat:
-            self._cacheable = self.cachestat.cacheable()
-        else:
-            # None means we don't know yet
-            self._cacheable = None
+        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
 
     def refresh(self):
         if self.cacheable():