diff 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
line wrap: on
line diff
--- a/tests/test-filecache.py	Thu Jan 10 23:54:53 2013 +0200
+++ b/tests/test-filecache.py	Mon Dec 17 15:25:45 2012 +0200
@@ -101,6 +101,17 @@
     # it
     repo.commit('.')
 
+def setbeforeget(repo):
+    os.remove('x')
+    repo.cached = 0
+    repo.invalidate()
+    print repo.cached
+    repo.invalidate()
+    f = open('x', 'w')
+    f.write('a')
+    f.close()
+    print repo.cached
+
 print 'basic:'
 print
 basic(fakerepo())
@@ -109,3 +120,7 @@
 print
 fakeuncacheable()
 test_filecache_synced()
+print
+print 'setbeforeget:'
+print
+setbeforeget(fakerepo())