Mercurial > public > mercurial-scm > hg
comparison tests/test-filecache.py @ 18316:f36375576ed5
filecache: create an entry in _filecache when __set__ is called for a missing one
Preserve the invariant that if P is a filecached property on X then
P in X.__dict__ => P in X._filecache.
Previously, it was possible for a filecached property to become out of sync
with the filesystem if it was set before getting it first, since the initial
filecacheentry was created in __get__.
Old behaviour:
repo.prop = x
repo.invalidate() # prop has no entry in _filecache, it's not removed
# from __dict__
repo.prop # returns x like before without checking with the
# filesystem
New:
repo.prop = x # an empty entry is created in _filecache
repo.invalidate() # prop is removed from __dict__
repo.prop # recreates prop
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Mon, 17 Dec 2012 15:25:45 +0200 |
parents | 3e4a944c0d04 |
children | ed80cecdfc57 |
comparison
equal
deleted
inserted
replaced
18315:216230643ae2 | 18316:f36375576ed5 |
---|---|
99 # but since changelog isn't under the filecache control anymore, we don't | 99 # but since changelog isn't under the filecache control anymore, we don't |
100 # see that it changed, and return the old changelog without reconstructing | 100 # see that it changed, and return the old changelog without reconstructing |
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 print | 116 print |
106 basic(fakerepo()) | 117 basic(fakerepo()) |
107 print | 118 print |
108 print 'fakeuncacheable:' | 119 print 'fakeuncacheable:' |
109 print | 120 print |
110 fakeuncacheable() | 121 fakeuncacheable() |
111 test_filecache_synced() | 122 test_filecache_synced() |
123 print | |
124 print 'setbeforeget:' | |
125 print | |
126 setbeforeget(fakerepo()) |