##// END OF EJS Templates
test: make test-propertycache.py python2.4 compatible...
Pierre-Yves David -
r19878:21de61bc stable
parent child Browse files
Show More
@@ -1,179 +1,179 b''
1 1 """test behavior of propertycache and unfiltered propertycache
2 2
3 3 The repoview overlay is quite complexe. We test the behavior of
4 4 property cache of both localrepo and repoview to prevent
5 5 regression."""
6 6
7 7 import os, subprocess
8 8 import mercurial.localrepo
9 9 import mercurial.repoview
10 10 import mercurial.util
11 11 import mercurial.hg
12 12 import mercurial.ui as uimod
13 13
14 14
15 15 # create some special property cache that trace they call
16 16
17 17 calllog = []
18 18 @mercurial.util.propertycache
19 19 def testcachedfoobar(repo):
20 20 name = repo.filtername
21 21 if name is None:
22 22 name = ''
23 23 val = len(name)
24 24 calllog.append(val)
25 25 return val
26 26
27 27 unficalllog = []
28 28 @mercurial.localrepo.unfilteredpropertycache
29 29 def testcachedunfifoobar(repo):
30 30 name = repo.filtername
31 31 if name is None:
32 32 name = ''
33 33 val = 100 + len(name)
34 34 unficalllog.append(val)
35 35 return val
36 36
37 37 #plug them on repo
38 38 mercurial.localrepo.localrepository.testcachedfoobar = testcachedfoobar
39 39 mercurial.localrepo.localrepository.testcachedunfifoobar = testcachedunfifoobar
40 40
41 41
42 42 # create an empty repo. and instanciate it. It is important to run
43 43 # those test on the real object to detect regression.
44 44 repopath = os.path.join(os.environ['TESTTMP'], 'repo')
45 subprocess.check_call(['hg', 'init', repopath])
45 assert subprocess.call(['hg', 'init', repopath]) == 0
46 46 ui = uimod.ui()
47 47 repo = mercurial.hg.repository(ui, path=repopath).unfiltered()
48 48
49 49
50 50 print ''
51 51 print '=== property cache ==='
52 52 print ''
53 53 print 'calllog:', calllog
54 54 print 'cached value (unfiltered):',
55 55 print vars(repo).get('testcachedfoobar', 'NOCACHE')
56 56
57 57 print ''
58 58 print '= first access on unfiltered, should do a call'
59 59 print 'access:', repo.testcachedfoobar
60 60 print 'calllog:', calllog
61 61 print 'cached value (unfiltered):',
62 62 print vars(repo).get('testcachedfoobar', 'NOCACHE')
63 63
64 64 print ''
65 65 print '= second access on unfiltered, should not do call'
66 66 print 'access', repo.testcachedfoobar
67 67 print 'calllog:', calllog
68 68 print 'cached value (unfiltered):',
69 69 print vars(repo).get('testcachedfoobar', 'NOCACHE')
70 70
71 71 print ''
72 72 print '= first access on "visible" view, should do a call'
73 73 visibleview = repo.filtered('visible')
74 74 print 'cached value ("visible" view):',
75 75 print vars(visibleview).get('testcachedfoobar', 'NOCACHE')
76 76 print 'access:', visibleview.testcachedfoobar
77 77 print 'calllog:', calllog
78 78 print 'cached value (unfiltered):',
79 79 print vars(repo).get('testcachedfoobar', 'NOCACHE')
80 80 print 'cached value ("visible" view):',
81 81 print vars(visibleview).get('testcachedfoobar', 'NOCACHE')
82 82
83 83 print ''
84 84 print '= second access on "visible view", should not do call'
85 85 print 'access:', visibleview.testcachedfoobar
86 86 print 'calllog:', calllog
87 87 print 'cached value (unfiltered):',
88 88 print vars(repo).get('testcachedfoobar', 'NOCACHE')
89 89 print 'cached value ("visible" view):',
90 90 print vars(visibleview).get('testcachedfoobar', 'NOCACHE')
91 91
92 92 print ''
93 93 print '= no effect on other view'
94 94 immutableview = repo.filtered('immutable')
95 95 print 'cached value ("immutable" view):',
96 96 print vars(immutableview).get('testcachedfoobar', 'NOCACHE')
97 97 print 'access:', immutableview.testcachedfoobar
98 98 print 'calllog:', calllog
99 99 print 'cached value (unfiltered):',
100 100 print vars(repo).get('testcachedfoobar', 'NOCACHE')
101 101 print 'cached value ("visible" view):',
102 102 print vars(visibleview).get('testcachedfoobar', 'NOCACHE')
103 103 print 'cached value ("immutable" view):',
104 104 print vars(immutableview).get('testcachedfoobar', 'NOCACHE')
105 105
106 106 # unfiltered property cache test
107 107 print ''
108 108 print ''
109 109 print '=== unfiltered property cache ==='
110 110 print ''
111 111 print 'unficalllog:', unficalllog
112 112 print 'cached value (unfiltered): ',
113 113 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
114 114 print 'cached value ("visible" view): ',
115 115 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
116 116 print 'cached value ("immutable" view):',
117 117 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
118 118
119 119 print ''
120 120 print '= first access on unfiltered, should do a call'
121 121 print 'access (unfiltered):', repo.testcachedunfifoobar
122 122 print 'unficalllog:', unficalllog
123 123 print 'cached value (unfiltered): ',
124 124 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
125 125
126 126 print ''
127 127 print '= second access on unfiltered, should not do call'
128 128 print 'access (unfiltered):', repo.testcachedunfifoobar
129 129 print 'unficalllog:', unficalllog
130 130 print 'cached value (unfiltered): ',
131 131 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
132 132
133 133 print ''
134 134 print '= access on view should use the unfiltered cache'
135 135 print 'access (unfiltered): ', repo.testcachedunfifoobar
136 136 print 'access ("visible" view): ', visibleview.testcachedunfifoobar
137 137 print 'access ("immutable" view):', immutableview.testcachedunfifoobar
138 138 print 'unficalllog:', unficalllog
139 139 print 'cached value (unfiltered): ',
140 140 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
141 141 print 'cached value ("visible" view): ',
142 142 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
143 143 print 'cached value ("immutable" view):',
144 144 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
145 145
146 146 print ''
147 147 print '= even if we clear the unfiltered cache'
148 148 del repo.__dict__['testcachedunfifoobar']
149 149 print 'cached value (unfiltered): ',
150 150 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
151 151 print 'cached value ("visible" view): ',
152 152 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
153 153 print 'cached value ("immutable" view):',
154 154 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
155 155 print 'unficalllog:', unficalllog
156 156 print 'access ("visible" view): ', visibleview.testcachedunfifoobar
157 157 print 'unficalllog:', unficalllog
158 158 print 'cached value (unfiltered): ',
159 159 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
160 160 print 'cached value ("visible" view): ',
161 161 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
162 162 print 'cached value ("immutable" view):',
163 163 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
164 164 print 'access ("immutable" view):', immutableview.testcachedunfifoobar
165 165 print 'unficalllog:', unficalllog
166 166 print 'cached value (unfiltered): ',
167 167 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
168 168 print 'cached value ("visible" view): ',
169 169 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
170 170 print 'cached value ("immutable" view):',
171 171 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
172 172 print 'access (unfiltered): ', repo.testcachedunfifoobar
173 173 print 'unficalllog:', unficalllog
174 174 print 'cached value (unfiltered): ',
175 175 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
176 176 print 'cached value ("visible" view): ',
177 177 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
178 178 print 'cached value ("immutable" view):',
179 179 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
General Comments 0
You need to be logged in to leave comments. Login now