Show More
@@ -950,6 +950,7 b' class filecache(object):' | |||||
950 | def __get__(self, obj, type=None): |
|
950 | def __get__(self, obj, type=None): | |
951 | # do we need to check if the file changed? |
|
951 | # do we need to check if the file changed? | |
952 | if self.name in obj.__dict__: |
|
952 | if self.name in obj.__dict__: | |
|
953 | assert self.name in obj._filecache, self.name | |||
953 | return obj.__dict__[self.name] |
|
954 | return obj.__dict__[self.name] | |
954 |
|
955 | |||
955 | entry = obj._filecache.get(self.name) |
|
956 | entry = obj._filecache.get(self.name) | |
@@ -971,8 +972,15 b' class filecache(object):' | |||||
971 | return entry.obj |
|
972 | return entry.obj | |
972 |
|
973 | |||
973 | def __set__(self, obj, value): |
|
974 | def __set__(self, obj, value): | |
974 | if self.name in obj._filecache: |
|
975 | if self.name not in obj._filecache: | |
975 | obj._filecache[self.name].obj = value # update cached copy |
|
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 | obj.__dict__[self.name] = value # update copy returned by obj.x |
|
984 | obj.__dict__[self.name] = value # update copy returned by obj.x | |
977 |
|
985 | |||
978 | def __delete__(self, obj): |
|
986 | def __delete__(self, obj): |
@@ -101,6 +101,17 b' def test_filecache_synced():' | |||||
101 | # it |
|
101 | # it | |
102 | repo.commit('.') |
|
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 | print 'basic:' |
|
115 | print 'basic:' | |
105 |
|
116 | |||
106 | basic(fakerepo()) |
|
117 | basic(fakerepo()) | |
@@ -109,3 +120,7 b" print 'fakeuncacheable:'" | |||||
109 |
|
120 | |||
110 | fakeuncacheable() |
|
121 | fakeuncacheable() | |
111 | test_filecache_synced() |
|
122 | test_filecache_synced() | |
|
123 | ||||
|
124 | print 'setbeforeget:' | |||
|
125 | ||||
|
126 | setbeforeget(fakerepo()) |
@@ -17,3 +17,9 b' repository tip rolled back to revision -' | |||||
17 | working directory now based on revision -1 |
|
17 | working directory now based on revision -1 | |
18 | repository tip rolled back to revision -1 (undo commit) |
|
18 | repository tip rolled back to revision -1 (undo commit) | |
19 | working directory now based on revision -1 |
|
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