Show More
@@ -39,7 +39,10 b' class unfilteredpropertycache(propertyca' | |||
|
39 | 39 | """propertycache that apply to unfiltered repo only""" |
|
40 | 40 | |
|
41 | 41 | def __get__(self, repo, type=None): |
|
42 | return super(unfilteredpropertycache, self).__get__(repo.unfiltered()) | |
|
42 | unfi = repo.unfiltered() | |
|
43 | if unfi is repo: | |
|
44 | return super(unfilteredpropertycache, self).__get__(unfi) | |
|
45 | return getattr(unfi, self.name) | |
|
43 | 46 | |
|
44 | 47 | class filteredpropertycache(propertycache): |
|
45 | 48 | """propertycache that must take filtering in account""" |
@@ -24,8 +24,19 b' def testcachedfoobar(repo):' | |||
|
24 | 24 | calllog.append(val) |
|
25 | 25 | return val |
|
26 | 26 | |
|
27 | unficalllog = [] | |
|
28 | @mercurial.localrepo.unfilteredpropertycache | |
|
29 | def testcachedunfifoobar(repo): | |
|
30 | name = repo.filtername | |
|
31 | if name is None: | |
|
32 | name = '' | |
|
33 | val = 100 + len(name) | |
|
34 | unficalllog.append(val) | |
|
35 | return val | |
|
36 | ||
|
27 | 37 | #plug them on repo |
|
28 | 38 | mercurial.localrepo.localrepository.testcachedfoobar = testcachedfoobar |
|
39 | mercurial.localrepo.localrepository.testcachedunfifoobar = testcachedunfifoobar | |
|
29 | 40 | |
|
30 | 41 | |
|
31 | 42 | # create an empty repo. and instanciate it. It is important to run |
@@ -92,3 +103,77 b" print vars(visibleview).get('testcachedf" | |||
|
92 | 103 | print 'cached value ("immutable" view):', |
|
93 | 104 | print vars(immutableview).get('testcachedfoobar', 'NOCACHE') |
|
94 | 105 | |
|
106 | # unfiltered property cache test | |
|
107 | print '' | |
|
108 | print '' | |
|
109 | print '=== unfiltered property cache ===' | |
|
110 | print '' | |
|
111 | print 'unficalllog:', unficalllog | |
|
112 | print 'cached value (unfiltered): ', | |
|
113 | print vars(repo).get('testcachedunfifoobar', 'NOCACHE') | |
|
114 | print 'cached value ("visible" view): ', | |
|
115 | print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') | |
|
116 | print 'cached value ("immutable" view):', | |
|
117 | print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') | |
|
118 | ||
|
119 | print '' | |
|
120 | print '= first access on unfiltered, should do a call' | |
|
121 | print 'access (unfiltered):', repo.testcachedunfifoobar | |
|
122 | print 'unficalllog:', unficalllog | |
|
123 | print 'cached value (unfiltered): ', | |
|
124 | print vars(repo).get('testcachedunfifoobar', 'NOCACHE') | |
|
125 | ||
|
126 | print '' | |
|
127 | print '= second access on unfiltered, should not do call' | |
|
128 | print 'access (unfiltered):', repo.testcachedunfifoobar | |
|
129 | print 'unficalllog:', unficalllog | |
|
130 | print 'cached value (unfiltered): ', | |
|
131 | print vars(repo).get('testcachedunfifoobar', 'NOCACHE') | |
|
132 | ||
|
133 | print '' | |
|
134 | print '= access on view should use the unfiltered cache' | |
|
135 | print 'access (unfiltered): ', repo.testcachedunfifoobar | |
|
136 | print 'access ("visible" view): ', visibleview.testcachedunfifoobar | |
|
137 | print 'access ("immutable" view):', immutableview.testcachedunfifoobar | |
|
138 | print 'unficalllog:', unficalllog | |
|
139 | print 'cached value (unfiltered): ', | |
|
140 | print vars(repo).get('testcachedunfifoobar', 'NOCACHE') | |
|
141 | print 'cached value ("visible" view): ', | |
|
142 | print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') | |
|
143 | print 'cached value ("immutable" view):', | |
|
144 | print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') | |
|
145 | ||
|
146 | print '' | |
|
147 | print '= even if we clear the unfiltered cache' | |
|
148 | del repo.__dict__['testcachedunfifoobar'] | |
|
149 | print 'cached value (unfiltered): ', | |
|
150 | print vars(repo).get('testcachedunfifoobar', 'NOCACHE') | |
|
151 | print 'cached value ("visible" view): ', | |
|
152 | print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') | |
|
153 | print 'cached value ("immutable" view):', | |
|
154 | print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') | |
|
155 | print 'unficalllog:', unficalllog | |
|
156 | print 'access ("visible" view): ', visibleview.testcachedunfifoobar | |
|
157 | print 'unficalllog:', unficalllog | |
|
158 | print 'cached value (unfiltered): ', | |
|
159 | print vars(repo).get('testcachedunfifoobar', 'NOCACHE') | |
|
160 | print 'cached value ("visible" view): ', | |
|
161 | print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') | |
|
162 | print 'cached value ("immutable" view):', | |
|
163 | print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') | |
|
164 | print 'access ("immutable" view):', immutableview.testcachedunfifoobar | |
|
165 | print 'unficalllog:', unficalllog | |
|
166 | print 'cached value (unfiltered): ', | |
|
167 | print vars(repo).get('testcachedunfifoobar', 'NOCACHE') | |
|
168 | print 'cached value ("visible" view): ', | |
|
169 | print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') | |
|
170 | print 'cached value ("immutable" view):', | |
|
171 | print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') | |
|
172 | print 'access (unfiltered): ', repo.testcachedunfifoobar | |
|
173 | print 'unficalllog:', unficalllog | |
|
174 | print 'cached value (unfiltered): ', | |
|
175 | print vars(repo).get('testcachedunfifoobar', 'NOCACHE') | |
|
176 | print 'cached value ("visible" view): ', | |
|
177 | print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE') | |
|
178 | print 'cached value ("immutable" view):', | |
|
179 | print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE') |
@@ -34,3 +34,51 b' calllog: [0, 7, 9]' | |||
|
34 | 34 | cached value (unfiltered): 0 |
|
35 | 35 | cached value ("visible" view): 7 |
|
36 | 36 | cached value ("immutable" view): 9 |
|
37 | ||
|
38 | ||
|
39 | === unfiltered property cache === | |
|
40 | ||
|
41 | unficalllog: [] | |
|
42 | cached value (unfiltered): NOCACHE | |
|
43 | cached value ("visible" view): NOCACHE | |
|
44 | cached value ("immutable" view): NOCACHE | |
|
45 | ||
|
46 | = first access on unfiltered, should do a call | |
|
47 | access (unfiltered): 100 | |
|
48 | unficalllog: [100] | |
|
49 | cached value (unfiltered): 100 | |
|
50 | ||
|
51 | = second access on unfiltered, should not do call | |
|
52 | access (unfiltered): 100 | |
|
53 | unficalllog: [100] | |
|
54 | cached value (unfiltered): 100 | |
|
55 | ||
|
56 | = access on view should use the unfiltered cache | |
|
57 | access (unfiltered): 100 | |
|
58 | access ("visible" view): 100 | |
|
59 | access ("immutable" view): 100 | |
|
60 | unficalllog: [100] | |
|
61 | cached value (unfiltered): 100 | |
|
62 | cached value ("visible" view): NOCACHE | |
|
63 | cached value ("immutable" view): NOCACHE | |
|
64 | ||
|
65 | = even if we clear the unfiltered cache | |
|
66 | cached value (unfiltered): NOCACHE | |
|
67 | cached value ("visible" view): NOCACHE | |
|
68 | cached value ("immutable" view): NOCACHE | |
|
69 | unficalllog: [100] | |
|
70 | access ("visible" view): 100 | |
|
71 | unficalllog: [100, 100] | |
|
72 | cached value (unfiltered): 100 | |
|
73 | cached value ("visible" view): NOCACHE | |
|
74 | cached value ("immutable" view): NOCACHE | |
|
75 | access ("immutable" view): 100 | |
|
76 | unficalllog: [100, 100] | |
|
77 | cached value (unfiltered): 100 | |
|
78 | cached value ("visible" view): NOCACHE | |
|
79 | cached value ("immutable" view): NOCACHE | |
|
80 | access (unfiltered): 100 | |
|
81 | unficalllog: [100, 100] | |
|
82 | cached value (unfiltered): 100 | |
|
83 | cached value ("visible" view): NOCACHE | |
|
84 | cached value ("immutable" view): NOCACHE |
General Comments 0
You need to be logged in to leave comments.
Login now