comparison tests/test-propertycache.py @ 28762:61ba04ae6a2f

py3: use print_function in test-propertycache.py
author Robert Stanca <robert.stanca7@gmail.com>
date Mon, 04 Apr 2016 04:56:05 +0300
parents 84673a7c54af
children a9a8b3f29544
comparison
equal deleted inserted replaced
28761:be13a0fb84e8 28762:61ba04ae6a2f
2 2
3 The repoview overlay is quite complex. We test the behavior of 3 The repoview overlay is quite complex. 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 from __future__ import absolute_import 7 from __future__ import absolute_import, print_function
8 import os 8 import os
9 import subprocess 9 import subprocess
10 import mercurial.localrepo 10 import mercurial.localrepo
11 import mercurial.repoview 11 import mercurial.repoview
12 import mercurial.util 12 import mercurial.util
47 assert subprocess.call(['hg', 'init', repopath]) == 0 47 assert subprocess.call(['hg', 'init', repopath]) == 0
48 ui = uimod.ui() 48 ui = uimod.ui()
49 repo = mercurial.hg.repository(ui, path=repopath).unfiltered() 49 repo = mercurial.hg.repository(ui, path=repopath).unfiltered()
50 50
51 51
52 print '' 52 print('')
53 print '=== property cache ===' 53 print('=== property cache ===')
54 print '' 54 print('')
55 print 'calllog:', calllog 55 print('calllog:', calllog)
56 print 'cached value (unfiltered):', 56 print('cached value (unfiltered):',
57 print vars(repo).get('testcachedfoobar', 'NOCACHE') 57 vars(repo).get('testcachedfoobar', 'NOCACHE'))
58 58
59 print '' 59 print('')
60 print '= first access on unfiltered, should do a call' 60 print('= first access on unfiltered, should do a call')
61 print 'access:', repo.testcachedfoobar 61 print('access:', repo.testcachedfoobar)
62 print 'calllog:', calllog 62 print('calllog:', calllog)
63 print 'cached value (unfiltered):', 63 print('cached value (unfiltered):',
64 print vars(repo).get('testcachedfoobar', 'NOCACHE') 64 vars(repo).get('testcachedfoobar', 'NOCACHE'))
65 65
66 print '' 66 print('')
67 print '= second access on unfiltered, should not do call' 67 print('= second access on unfiltered, should not do call')
68 print 'access', repo.testcachedfoobar 68 print('access', repo.testcachedfoobar)
69 print 'calllog:', calllog 69 print('calllog:', calllog)
70 print 'cached value (unfiltered):', 70 print('cached value (unfiltered):',
71 print vars(repo).get('testcachedfoobar', 'NOCACHE') 71 vars(repo).get('testcachedfoobar', 'NOCACHE'))
72 72
73 print '' 73 print('')
74 print '= first access on "visible" view, should do a call' 74 print('= first access on "visible" view, should do a call')
75 visibleview = repo.filtered('visible') 75 visibleview = repo.filtered('visible')
76 print 'cached value ("visible" view):', 76 print('cached value ("visible" view):',
77 print vars(visibleview).get('testcachedfoobar', 'NOCACHE') 77 vars(visibleview).get('testcachedfoobar', 'NOCACHE'))
78 print 'access:', visibleview.testcachedfoobar 78 print('access:', visibleview.testcachedfoobar)
79 print 'calllog:', calllog 79 print('calllog:', calllog)
80 print 'cached value (unfiltered):', 80 print('cached value (unfiltered):',
81 print vars(repo).get('testcachedfoobar', 'NOCACHE') 81 vars(repo).get('testcachedfoobar', 'NOCACHE'))
82 print 'cached value ("visible" view):', 82 print('cached value ("visible" view):',
83 print vars(visibleview).get('testcachedfoobar', 'NOCACHE') 83 vars(visibleview).get('testcachedfoobar', 'NOCACHE'))
84 84
85 print '' 85 print('')
86 print '= second access on "visible view", should not do call' 86 print('= second access on "visible view", should not do call')
87 print 'access:', visibleview.testcachedfoobar 87 print('access:', visibleview.testcachedfoobar)
88 print 'calllog:', calllog 88 print('calllog:', calllog)
89 print 'cached value (unfiltered):', 89 print('cached value (unfiltered):',
90 print vars(repo).get('testcachedfoobar', 'NOCACHE') 90 vars(repo).get('testcachedfoobar', 'NOCACHE'))
91 print 'cached value ("visible" view):', 91 print('cached value ("visible" view):',
92 print vars(visibleview).get('testcachedfoobar', 'NOCACHE') 92 vars(visibleview).get('testcachedfoobar', 'NOCACHE'))
93 93
94 print '' 94 print('')
95 print '= no effect on other view' 95 print('= no effect on other view')
96 immutableview = repo.filtered('immutable') 96 immutableview = repo.filtered('immutable')
97 print 'cached value ("immutable" view):', 97 print('cached value ("immutable" view):',
98 print vars(immutableview).get('testcachedfoobar', 'NOCACHE') 98 vars(immutableview).get('testcachedfoobar', 'NOCACHE'))
99 print 'access:', immutableview.testcachedfoobar 99 print('access:', immutableview.testcachedfoobar)
100 print 'calllog:', calllog 100 print('calllog:', calllog)
101 print 'cached value (unfiltered):', 101 print('cached value (unfiltered):',
102 print vars(repo).get('testcachedfoobar', 'NOCACHE') 102 vars(repo).get('testcachedfoobar', 'NOCACHE'))
103 print 'cached value ("visible" view):', 103 print('cached value ("visible" view):',
104 print vars(visibleview).get('testcachedfoobar', 'NOCACHE') 104 vars(visibleview).get('testcachedfoobar', 'NOCACHE'))
105 print 'cached value ("immutable" view):', 105 print('cached value ("immutable" view):',
106 print vars(immutableview).get('testcachedfoobar', 'NOCACHE') 106 vars(immutableview).get('testcachedfoobar', 'NOCACHE'))
107 107
108 # unfiltered property cache test 108 # unfiltered property cache test
109 print '' 109 print('')
110 print '' 110 print('')
111 print '=== unfiltered property cache ===' 111 print('=== unfiltered property cache ===')
112 print '' 112 print('')
113 print 'unficalllog:', unficalllog 113 print('unficalllog:', unficalllog)
114 print 'cached value (unfiltered): ', 114 print('cached value (unfiltered): ',
115 print vars(repo).get('testcachedunfifoobar', 'NOCACHE') 115 vars(repo).get('testcachedunfifoobar', 'NOCACHE'))
116 print 'cached value ("visible" view): ', 116 print('cached value ("visible" view): ',
117 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') 117 vars(visibleview).get('testcachedunfifoobar', 'NOCACHE'))
118 print 'cached value ("immutable" view):', 118 print('cached value ("immutable" view):',
119 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') 119 vars(immutableview).get('testcachedunfifoobar', 'NOCACHE'))
120 120
121 print '' 121 print('')
122 print '= first access on unfiltered, should do a call' 122 print('= first access on unfiltered, should do a call')
123 print 'access (unfiltered):', repo.testcachedunfifoobar 123 print('access (unfiltered):', repo.testcachedunfifoobar)
124 print 'unficalllog:', unficalllog 124 print('unficalllog:', unficalllog)
125 print 'cached value (unfiltered): ', 125 print('cached value (unfiltered): ',
126 print vars(repo).get('testcachedunfifoobar', 'NOCACHE') 126 vars(repo).get('testcachedunfifoobar', 'NOCACHE'))
127 127
128 print '' 128 print('')
129 print '= second access on unfiltered, should not do call' 129 print('= second access on unfiltered, should not do call')
130 print 'access (unfiltered):', repo.testcachedunfifoobar 130 print('access (unfiltered):', repo.testcachedunfifoobar)
131 print 'unficalllog:', unficalllog 131 print('unficalllog:', unficalllog)
132 print 'cached value (unfiltered): ', 132 print('cached value (unfiltered): ',
133 print vars(repo).get('testcachedunfifoobar', 'NOCACHE') 133 vars(repo).get('testcachedunfifoobar', 'NOCACHE'))
134 134
135 print '' 135 print('')
136 print '= access on view should use the unfiltered cache' 136 print('= access on view should use the unfiltered cache')
137 print 'access (unfiltered): ', repo.testcachedunfifoobar 137 print('access (unfiltered): ', repo.testcachedunfifoobar)
138 print 'access ("visible" view): ', visibleview.testcachedunfifoobar 138 print('access ("visible" view): ', visibleview.testcachedunfifoobar)
139 print 'access ("immutable" view):', immutableview.testcachedunfifoobar 139 print('access ("immutable" view):', immutableview.testcachedunfifoobar)
140 print 'unficalllog:', unficalllog 140 print('unficalllog:', unficalllog)
141 print 'cached value (unfiltered): ', 141 print('cached value (unfiltered): ',
142 print vars(repo).get('testcachedunfifoobar', 'NOCACHE') 142 vars(repo).get('testcachedunfifoobar', 'NOCACHE'))
143 print 'cached value ("visible" view): ', 143 print('cached value ("visible" view): ',
144 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') 144 vars(visibleview).get('testcachedunfifoobar', 'NOCACHE'))
145 print 'cached value ("immutable" view):', 145 print('cached value ("immutable" view):',
146 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') 146 vars(immutableview).get('testcachedunfifoobar', 'NOCACHE'))
147 147
148 print '' 148 print('')
149 print '= even if we clear the unfiltered cache' 149 print('= even if we clear the unfiltered cache')
150 del repo.__dict__['testcachedunfifoobar'] 150 del repo.__dict__['testcachedunfifoobar']
151 print 'cached value (unfiltered): ', 151 print('cached value (unfiltered): ',
152 print vars(repo).get('testcachedunfifoobar', 'NOCACHE') 152 vars(repo).get('testcachedunfifoobar', 'NOCACHE'))
153 print 'cached value ("visible" view): ', 153 print('cached value ("visible" view): ',
154 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') 154 vars(visibleview).get('testcachedunfifoobar', 'NOCACHE'))
155 print 'cached value ("immutable" view):', 155 print('cached value ("immutable" view):',
156 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') 156 vars(immutableview).get('testcachedunfifoobar', 'NOCACHE'))
157 print 'unficalllog:', unficalllog 157 print('unficalllog:', unficalllog)
158 print 'access ("visible" view): ', visibleview.testcachedunfifoobar 158 print('access ("visible" view): ', visibleview.testcachedunfifoobar)
159 print 'unficalllog:', unficalllog 159 print('unficalllog:', unficalllog)
160 print 'cached value (unfiltered): ', 160 print('cached value (unfiltered): ',
161 print vars(repo).get('testcachedunfifoobar', 'NOCACHE') 161 vars(repo).get('testcachedunfifoobar', 'NOCACHE'))
162 print 'cached value ("visible" view): ', 162 print('cached value ("visible" view): ',
163 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') 163 vars(visibleview).get('testcachedunfifoobar', 'NOCACHE'))
164 print 'cached value ("immutable" view):', 164 print('cached value ("immutable" view):',
165 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') 165 vars(immutableview).get('testcachedunfifoobar', 'NOCACHE'))
166 print 'access ("immutable" view):', immutableview.testcachedunfifoobar 166 print('access ("immutable" view):', immutableview.testcachedunfifoobar)
167 print 'unficalllog:', unficalllog 167 print('unficalllog:', unficalllog)
168 print 'cached value (unfiltered): ', 168 print('cached value (unfiltered): ',
169 print vars(repo).get('testcachedunfifoobar', 'NOCACHE') 169 vars(repo).get('testcachedunfifoobar', 'NOCACHE'))
170 print 'cached value ("visible" view): ', 170 print('cached value ("visible" view): ',
171 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') 171 vars(visibleview).get('testcachedunfifoobar', 'NOCACHE'))
172 print 'cached value ("immutable" view):', 172 print('cached value ("immutable" view):',
173 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') 173 vars(immutableview).get('testcachedunfifoobar', 'NOCACHE'))
174 print 'access (unfiltered): ', repo.testcachedunfifoobar 174 print('access (unfiltered): ', repo.testcachedunfifoobar)
175 print 'unficalllog:', unficalllog 175 print('unficalllog:', unficalllog)
176 print 'cached value (unfiltered): ', 176 print('cached value (unfiltered): ',
177 print vars(repo).get('testcachedunfifoobar', 'NOCACHE') 177 vars(repo).get('testcachedunfifoobar', 'NOCACHE'))
178 print 'cached value ("visible" view): ', 178 print('cached value ("visible" view): ',
179 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') 179 vars(visibleview).get('testcachedunfifoobar', 'NOCACHE'))
180 print 'cached value ("immutable" view):', 180 print('cached value ("immutable" view):',
181 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') 181 vars(immutableview).get('testcachedunfifoobar', 'NOCACHE'))