mercurial/scmutil.py
changeset 18316 f36375576ed5
parent 18315 216230643ae2
child 18327 4aecdb91443c
--- a/mercurial/scmutil.py	Thu Jan 10 23:54:53 2013 +0200
+++ b/mercurial/scmutil.py	Mon Dec 17 15:25:45 2012 +0200
@@ -950,6 +950,7 @@
     def __get__(self, obj, type=None):
         # do we need to check if the file changed?
         if self.name in obj.__dict__:
+            assert self.name in obj._filecache, self.name
             return obj.__dict__[self.name]
 
         entry = obj._filecache.get(self.name)
@@ -971,8 +972,15 @@
         return entry.obj
 
     def __set__(self, obj, value):
-        if self.name in obj._filecache:
-            obj._filecache[self.name].obj = value # update cached copy
+        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)
+            obj._filecache[self.name] = ce
+        else:
+            ce = obj._filecache[self.name]
+
+        ce.obj = value # update cached copy
         obj.__dict__[self.name] = value # update copy returned by obj.x
 
     def __delete__(self, obj):