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