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 | |
|
106 | 117 | basic(fakerepo()) |
@@ -109,3 +120,7 b" print 'fakeuncacheable:'" | |||
|
109 | 120 | |
|
110 | 121 | fakeuncacheable() |
|
111 | 122 | test_filecache_synced() |
|
123 | ||
|
124 | print 'setbeforeget:' | |
|
125 | ||
|
126 | setbeforeget(fakerepo()) |
General Comments 0
You need to be logged in to leave comments.
Login now