annotate tests/test-filecache.py @ 29481:5caa415aa48b

tests: better testing of loaded certificates Tests were failing on systems like RHEL 7 where loading the system certificates results in CA certs being reported to Python. We add a feature that detects when we're able to load *and detect* the loading of system certificates. We update the tests to cover the 3 scenarios: 1) system CAs are loadable and detected 2) system CAs are loadable but not detected 3) system CAs aren't loadable
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 01 Jul 2016 19:27:34 -0700
parents 76c091f9711e
children 57830bd0e787
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
1 from __future__ import absolute_import, print_function
28741
fc5f548393bf py3: use absolute_import in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 26098
diff changeset
2 import os
fc5f548393bf py3: use absolute_import in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 26098
diff changeset
3 import subprocess
fc5f548393bf py3: use absolute_import in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 26098
diff changeset
4 import sys
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 15518
diff changeset
6 if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'],
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 15518
diff changeset
7 'cacheable']):
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8 sys.exit(80)
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9
28802
b16eacf5347c test-filecache: sort import lines
Yuya Nishihara <yuya@tcha.org>
parents: 28742
diff changeset
10 from mercurial import (
b16eacf5347c test-filecache: sort import lines
Yuya Nishihara <yuya@tcha.org>
parents: 28742
diff changeset
11 extensions,
b16eacf5347c test-filecache: sort import lines
Yuya Nishihara <yuya@tcha.org>
parents: 28742
diff changeset
12 hg,
b16eacf5347c test-filecache: sort import lines
Yuya Nishihara <yuya@tcha.org>
parents: 28742
diff changeset
13 scmutil,
28803
76c091f9711e test-filecache: alias ui as uimod
Yuya Nishihara <yuya@tcha.org>
parents: 28802
diff changeset
14 ui as uimod,
28802
b16eacf5347c test-filecache: sort import lines
Yuya Nishihara <yuya@tcha.org>
parents: 28742
diff changeset
15 util,
b16eacf5347c test-filecache: sort import lines
Yuya Nishihara <yuya@tcha.org>
parents: 28742
diff changeset
16 )
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 filecache = scmutil.filecache
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 class fakerepo(object):
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 def __init__(self):
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 self._filecache = {}
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 def join(self, p):
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 return p
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 def sjoin(self, p):
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28 return p
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
30 @filecache('x', 'y')
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31 def cached(self):
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
32 print('creating')
20040
ed80cecdfc57 test-filecache.py: make setbeforeget test clearer
Siddharth Agarwal <sid0@fb.com>
parents: 18316
diff changeset
33 return 'string from function'
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
34
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
35 def invalidate(self):
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
36 for k in self._filecache:
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
37 try:
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
38 delattr(self, k)
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
39 except AttributeError:
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
40 pass
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
41
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
42 def basic(repo):
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
43 print("* neither file exists")
20041
42deff43460a test-filecache.py: add markers to the output for each event
Siddharth Agarwal <sid0@fb.com>
parents: 20040
diff changeset
44 # calls function
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
45 repo.cached
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
46
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
47 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
48 print("* neither file still exists")
20041
42deff43460a test-filecache.py: add markers to the output for each event
Siddharth Agarwal <sid0@fb.com>
parents: 20040
diff changeset
49 # uses cache
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
50 repo.cached
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
51
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
52 # create empty file
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
53 f = open('x', 'w')
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
54 f.close()
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
55 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
56 print("* empty file x created")
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
57 # should recreate the object
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
58 repo.cached
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
59
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
60 f = open('x', 'w')
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
61 f.write('a')
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
62 f.close()
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
63 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
64 print("* file x changed size")
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
65 # should recreate the object
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
66 repo.cached
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
67
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
68 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
69 print("* nothing changed with either file")
20041
42deff43460a test-filecache.py: add markers to the output for each event
Siddharth Agarwal <sid0@fb.com>
parents: 20040
diff changeset
70 # stats file again, reuses object
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
71 repo.cached
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
72
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
73 # atomic replace file, size doesn't change
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
74 # hopefully st_mtime doesn't change as well so this doesn't use the cache
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
75 # because of inode change
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
76 f = scmutil.opener('.')('x', 'w', atomictemp=True)
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
77 f.write('b')
15057
774da7121fc9 atomictempfile: make close() consistent with other file-like objects.
Greg Ward <greg@gerg.ca>
parents: 14982
diff changeset
78 f.close()
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
79
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
80 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
81 print("* file x changed inode")
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
82 repo.cached
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
83
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
84 # create empty file y
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
85 f = open('y', 'w')
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
86 f.close()
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
87 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
88 print("* empty file y created")
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
89 # should recreate the object
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
90 repo.cached
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
91
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
92 f = open('y', 'w')
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
93 f.write('A')
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
94 f.close()
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
95 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
96 print("* file y changed size")
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
97 # should recreate the object
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
98 repo.cached
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
99
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
100 f = scmutil.opener('.')('y', 'w', atomictemp=True)
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
101 f.write('B')
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
102 f.close()
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
103
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
104 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
105 print("* file y changed inode")
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
106 repo.cached
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
107
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
108 f = scmutil.opener('.')('x', 'w', atomictemp=True)
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
109 f.write('c')
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
110 f.close()
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
111 f = scmutil.opener('.')('y', 'w', atomictemp=True)
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
112 f.write('C')
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
113 f.close()
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
114
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
115 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
116 print("* both files changed inode")
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
117 repo.cached
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
118
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
119 def fakeuncacheable():
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
120 def wrapcacheable(orig, *args, **kwargs):
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
121 return False
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
122
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
123 def wrapinit(orig, *args, **kwargs):
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
124 pass
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
125
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
126 originit = extensions.wrapfunction(util.cachestat, '__init__', wrapinit)
14937
0b3e57c1b8c0 filecache: fix check-code complaint
Matt Mackall <mpm@selenic.com>
parents: 14928
diff changeset
127 origcacheable = extensions.wrapfunction(util.cachestat, 'cacheable',
0b3e57c1b8c0 filecache: fix check-code complaint
Matt Mackall <mpm@selenic.com>
parents: 14928
diff changeset
128 wrapcacheable)
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
129
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
130 for fn in ['x', 'y']:
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
131 try:
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
132 os.remove(fn)
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
133 except OSError:
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
134 pass
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
135
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
136 basic(fakerepo())
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
137
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
138 util.cachestat.cacheable = origcacheable
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
139 util.cachestat.__init__ = originit
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
140
18313
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
141 def test_filecache_synced():
26098
ce26928cbe41 spelling: behaviour -> behavior
timeless@mozdev.org
parents: 20045
diff changeset
142 # test old behavior that caused filecached properties to go out of sync
18313
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
143 os.system('hg init && echo a >> a && hg ci -qAm.')
28803
76c091f9711e test-filecache: alias ui as uimod
Yuya Nishihara <yuya@tcha.org>
parents: 28802
diff changeset
144 repo = hg.repository(uimod.ui())
18313
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
145 # first rollback clears the filecache, but changelog to stays in __dict__
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
146 repo.rollback()
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
147 repo.commit('.')
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
148 # second rollback comes along and touches the changelog externally
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
149 # (file is moved)
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
150 repo.rollback()
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
151 # but since changelog isn't under the filecache control anymore, we don't
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
152 # see that it changed, and return the old changelog without reconstructing
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
153 # it
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
154 repo.commit('.')
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
155
18316
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
156 def setbeforeget(repo):
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
157 os.remove('x')
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
158 os.remove('y')
20040
ed80cecdfc57 test-filecache.py: make setbeforeget test clearer
Siddharth Agarwal <sid0@fb.com>
parents: 18316
diff changeset
159 repo.cached = 'string set externally'
18316
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
160 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
161 print("* neither file exists")
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
162 print(repo.cached)
18316
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
163 repo.invalidate()
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
164 f = open('x', 'w')
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
165 f.write('a')
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
166 f.close()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
167 print("* file x created")
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
168 print(repo.cached)
18316
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
169
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
170 repo.cached = 'string 2 set externally'
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
171 repo.invalidate()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
172 print("* string set externally again")
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
173 print(repo.cached)
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
174
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
175 repo.invalidate()
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
176 f = open('y', 'w')
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
177 f.write('b')
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
178 f.close()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
179 print("* file y created")
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
180 print(repo.cached)
20045
b3684fd2ff1a scmutil.filecache: support watching over multiple files
Siddharth Agarwal <sid0@fb.com>
parents: 20041
diff changeset
181
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
182 print('basic:')
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
183 print()
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
184 basic(fakerepo())
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
185 print()
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
186 print('fakeuncacheable:')
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
187 print()
14928
dca59d5be12d scmutil: introduce filecache
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
188 fakeuncacheable()
18313
3e4a944c0d04 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
Idan Kamara <idankk86@gmail.com>
parents: 16688
diff changeset
189 test_filecache_synced()
28742
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
190 print()
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
191 print('setbeforeget:')
a08c90d622eb py3: use print_function in test-filecache.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28741
diff changeset
192 print()
18316
f36375576ed5 filecache: create an entry in _filecache when __set__ is called for a missing one
Idan Kamara <idankk86@gmail.com>
parents: 18313
diff changeset
193 setbeforeget(fakerepo())