mercurial/scmutil.py
branchstable
changeset 16115 236bb604dc39
parent 16068 73aaff46175b
child 16167 94a8396c9305
child 16198 fa8488565afd
--- a/mercurial/scmutil.py	Wed Feb 15 23:44:10 2012 +0200
+++ b/mercurial/scmutil.py	Wed Feb 15 20:02:35 2012 +0200
@@ -803,6 +803,10 @@
         return self
 
     def __get__(self, obj, type=None):
+        # do we need to check if the file changed?
+        if self.name in obj.__dict__:
+            return obj.__dict__[self.name]
+
         entry = obj._filecache.get(self.name)
 
         if entry:
@@ -818,5 +822,16 @@
 
             obj._filecache[self.name] = entry
 
-        setattr(obj, self.name, entry.obj)
+        obj.__dict__[self.name] = entry.obj
         return entry.obj
+
+    def __set__(self, obj, value):
+        if self.name in obj._filecache:
+            obj._filecache[self.name].obj = value # update cached copy
+        obj.__dict__[self.name] = value # update copy returned by obj.x
+
+    def __delete__(self, obj):
+        try:
+            del obj.__dict__[self.name]
+        except KeyError:
+            raise AttributeError, self.name