Show More
@@ -7,6 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from node import bin, hex, nullid, nullrev |
|
8 | from node import bin, hex, nullid, nullrev | |
9 | import encoding |
|
9 | import encoding | |
|
10 | import scmutil | |||
10 | import util |
|
11 | import util | |
11 | import time |
|
12 | import time | |
12 | from array import array |
|
13 | from array import array | |
@@ -136,27 +137,6 b' class branchcache(dict):' | |||||
136 | else: |
|
137 | else: | |
137 | self._closednodes = closednodes |
|
138 | self._closednodes = closednodes | |
138 |
|
139 | |||
139 | def _hashfiltered(self, repo): |
|
|||
140 | """build hash of revision filtered in the current cache |
|
|||
141 |
|
||||
142 | Tracking tipnode and tiprev is not enough to ensure validity of the |
|
|||
143 | cache as they do not help to distinct cache that ignored various |
|
|||
144 | revision bellow tiprev. |
|
|||
145 |
|
||||
146 | To detect such difference, we build a cache of all ignored revisions. |
|
|||
147 | """ |
|
|||
148 | cl = repo.changelog |
|
|||
149 | if not cl.filteredrevs: |
|
|||
150 | return None |
|
|||
151 | key = None |
|
|||
152 | revs = sorted(r for r in cl.filteredrevs if r <= self.tiprev) |
|
|||
153 | if revs: |
|
|||
154 | s = util.sha1() |
|
|||
155 | for rev in revs: |
|
|||
156 | s.update('%s;' % rev) |
|
|||
157 | key = s.digest() |
|
|||
158 | return key |
|
|||
159 |
|
||||
160 | def validfor(self, repo): |
|
140 | def validfor(self, repo): | |
161 | """Is the cache content valid regarding a repo |
|
141 | """Is the cache content valid regarding a repo | |
162 |
|
142 | |||
@@ -164,7 +144,8 b' class branchcache(dict):' | |||||
164 | - True when cache is up to date or a subset of current repo.""" |
|
144 | - True when cache is up to date or a subset of current repo.""" | |
165 | try: |
|
145 | try: | |
166 | return ((self.tipnode == repo.changelog.node(self.tiprev)) |
|
146 | return ((self.tipnode == repo.changelog.node(self.tiprev)) | |
167 |
and (self.filteredhash == |
|
147 | and (self.filteredhash == \ | |
|
148 | scmutil.filteredhash(repo, self.tiprev))) | |||
168 | except IndexError: |
|
149 | except IndexError: | |
169 | return False |
|
150 | return False | |
170 |
|
151 | |||
@@ -283,7 +264,7 b' class branchcache(dict):' | |||||
283 | if tiprev > self.tiprev: |
|
264 | if tiprev > self.tiprev: | |
284 | self.tipnode = cl.node(tiprev) |
|
265 | self.tipnode = cl.node(tiprev) | |
285 | self.tiprev = tiprev |
|
266 | self.tiprev = tiprev | |
286 |
self.filteredhash = self. |
|
267 | self.filteredhash = scmutil.filteredhash(repo, self.tiprev) | |
287 |
|
268 | |||
288 | duration = time.time() - starttime |
|
269 | duration = time.time() - starttime | |
289 | repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n', |
|
270 | repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n', |
@@ -172,6 +172,30 b' class casecollisionauditor(object):' | |||||
172 | self._loweredfiles.add(fl) |
|
172 | self._loweredfiles.add(fl) | |
173 | self._newfiles.add(f) |
|
173 | self._newfiles.add(f) | |
174 |
|
174 | |||
|
175 | def filteredhash(repo, maxrev): | |||
|
176 | """build hash of filtered revisions in the current repoview. | |||
|
177 | ||||
|
178 | Multiple caches perform up-to-date validation by checking that the | |||
|
179 | tiprev and tipnode stored in the cache file match the current repository. | |||
|
180 | However, this is not sufficient for validating repoviews because the set | |||
|
181 | of revisions in the view may change without the repository tiprev and | |||
|
182 | tipnode changing. | |||
|
183 | ||||
|
184 | This function hashes all the revs filtered from the view and returns | |||
|
185 | that SHA-1 digest. | |||
|
186 | """ | |||
|
187 | cl = repo.changelog | |||
|
188 | if not cl.filteredrevs: | |||
|
189 | return None | |||
|
190 | key = None | |||
|
191 | revs = sorted(r for r in cl.filteredrevs if r <= maxrev) | |||
|
192 | if revs: | |||
|
193 | s = util.sha1() | |||
|
194 | for rev in revs: | |||
|
195 | s.update('%s;' % rev) | |||
|
196 | key = s.digest() | |||
|
197 | return key | |||
|
198 | ||||
175 | class abstractvfs(object): |
|
199 | class abstractvfs(object): | |
176 | """Abstract base class; cannot be instantiated""" |
|
200 | """Abstract base class; cannot be instantiated""" | |
177 |
|
201 |
General Comments 0
You need to be logged in to leave comments.
Login now