##// END OF EJS Templates
filecache: create an entry in _filecache when __set__ is called for a missing one...
Idan Kamara -
r18316:f3637557 default
parent child Browse files
Show More
@@ -950,6 +950,7 b' class filecache(object):'
950 950 def __get__(self, obj, type=None):
951 951 # do we need to check if the file changed?
952 952 if self.name in obj.__dict__:
953 assert self.name in obj._filecache, self.name
953 954 return obj.__dict__[self.name]
954 955
955 956 entry = obj._filecache.get(self.name)
@@ -971,8 +972,15 b' class filecache(object):'
971 972 return entry.obj
972 973
973 974 def __set__(self, obj, value):
974 if self.name in obj._filecache:
975 obj._filecache[self.name].obj = value # update cached copy
975 if self.name not in obj._filecache:
976 # we add an entry for the missing value because X in __dict__
977 # implies X in _filecache
978 ce = filecacheentry(self.join(obj, self.path), False)
979 obj._filecache[self.name] = ce
980 else:
981 ce = obj._filecache[self.name]
982
983 ce.obj = value # update cached copy
976 984 obj.__dict__[self.name] = value # update copy returned by obj.x
977 985
978 986 def __delete__(self, obj):
@@ -101,6 +101,17 b' def test_filecache_synced():'
101 101 # it
102 102 repo.commit('.')
103 103
104 def setbeforeget(repo):
105 os.remove('x')
106 repo.cached = 0
107 repo.invalidate()
108 print repo.cached
109 repo.invalidate()
110 f = open('x', 'w')
111 f.write('a')
112 f.close()
113 print repo.cached
114
104 115 print 'basic:'
105 116 print
106 117 basic(fakerepo())
@@ -109,3 +120,7 b" print 'fakeuncacheable:'"
109 120 print
110 121 fakeuncacheable()
111 122 test_filecache_synced()
123 print
124 print 'setbeforeget:'
125 print
126 setbeforeget(fakerepo())
@@ -17,3 +17,9 b' repository tip rolled back to revision -'
17 17 working directory now based on revision -1
18 18 repository tip rolled back to revision -1 (undo commit)
19 19 working directory now based on revision -1
20
21 setbeforeget:
22
23 0
24 creating
25 None
General Comments 0
You need to be logged in to leave comments. Login now