##// END OF EJS Templates
tests: port test-filecache.py to Python 3...
Augie Fackler -
r37917:b3ffa2fa default
parent child Browse files
Show More
@@ -147,6 +147,7 b' test-extdata.t'
147 test-extdiff.t
147 test-extdiff.t
148 test-extra-filelog-entry.t
148 test-extra-filelog-entry.t
149 test-filebranch.t
149 test-filebranch.t
150 test-filecache.py
150 test-fileset-generated.t
151 test-fileset-generated.t
151 test-fix-topology.t
152 test-fix-topology.t
152 test-flags.t
153 test-flags.t
@@ -8,6 +8,16 b" if subprocess.call(['python', '%s/hghave"
8 'cacheable']):
8 'cacheable']):
9 sys.exit(80)
9 sys.exit(80)
10
10
11 print_ = print
12 def print(*args, **kwargs):
13 """print() wrapper that flushes stdout buffers to avoid py3 buffer issues
14
15 We could also just write directly to sys.stdout.buffer the way the
16 ui object will, but this was easier for porting the test.
17 """
18 print_(*args, **kwargs)
19 sys.stdout.flush()
20
11 from mercurial import (
21 from mercurial import (
12 extensions,
22 extensions,
13 hg,
23 hg,
@@ -46,7 +56,7 b' class fakerepo(object):'
46 def invalidate(self):
56 def invalidate(self):
47 for k in self._filecache:
57 for k in self._filecache:
48 try:
58 try:
49 delattr(self, k)
59 delattr(self, pycompat.sysstr(k))
50 except AttributeError:
60 except AttributeError:
51 pass
61 pass
52
62
@@ -84,8 +94,8 b' def basic(repo):'
84 # atomic replace file, size doesn't change
94 # atomic replace file, size doesn't change
85 # hopefully st_mtime doesn't change as well so this doesn't use the cache
95 # hopefully st_mtime doesn't change as well so this doesn't use the cache
86 # because of inode change
96 # because of inode change
87 f = vfsmod.vfs('.')('x', 'w', atomictemp=True)
97 f = vfsmod.vfs(b'.')(b'x', b'w', atomictemp=True)
88 f.write('b')
98 f.write(b'b')
89 f.close()
99 f.close()
90
100
91 repo.invalidate()
101 repo.invalidate()
@@ -108,19 +118,19 b' def basic(repo):'
108 # should recreate the object
118 # should recreate the object
109 repo.cached
119 repo.cached
110
120
111 f = vfsmod.vfs('.')('y', 'w', atomictemp=True)
121 f = vfsmod.vfs(b'.')(b'y', b'w', atomictemp=True)
112 f.write('B')
122 f.write(b'B')
113 f.close()
123 f.close()
114
124
115 repo.invalidate()
125 repo.invalidate()
116 print("* file y changed inode")
126 print("* file y changed inode")
117 repo.cached
127 repo.cached
118
128
119 f = vfsmod.vfs('.')('x', 'w', atomictemp=True)
129 f = vfsmod.vfs(b'.')(b'x', b'w', atomictemp=True)
120 f.write('c')
130 f.write(b'c')
121 f.close()
131 f.close()
122 f = vfsmod.vfs('.')('y', 'w', atomictemp=True)
132 f = vfsmod.vfs(b'.')(b'y', b'w', atomictemp=True)
123 f.write('C')
133 f.write(b'C')
124 f.close()
134 f.close()
125
135
126 repo.invalidate()
136 repo.invalidate()
@@ -155,14 +165,14 b' def test_filecache_synced():'
155 repo = hg.repository(uimod.ui.load())
165 repo = hg.repository(uimod.ui.load())
156 # first rollback clears the filecache, but changelog to stays in __dict__
166 # first rollback clears the filecache, but changelog to stays in __dict__
157 repo.rollback()
167 repo.rollback()
158 repo.commit('.')
168 repo.commit(b'.')
159 # second rollback comes along and touches the changelog externally
169 # second rollback comes along and touches the changelog externally
160 # (file is moved)
170 # (file is moved)
161 repo.rollback()
171 repo.rollback()
162 # but since changelog isn't under the filecache control anymore, we don't
172 # but since changelog isn't under the filecache control anymore, we don't
163 # see that it changed, and return the old changelog without reconstructing
173 # see that it changed, and return the old changelog without reconstructing
164 # it
174 # it
165 repo.commit('.')
175 repo.commit(b'.')
166
176
167 def setbeforeget(repo):
177 def setbeforeget(repo):
168 os.remove('x')
178 os.remove('x')
General Comments 0
You need to be logged in to leave comments. Login now