Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 24723:467a33142425
repoview: move function for computing filtered hash
An upcoming patch will establish per-filter tags caches. We'll want
to use the same cache validation logic as the branch cache. Prepare
for that by moving the logic for computing a filtered view hash
to somewhere central.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 01 Apr 2015 18:43:29 -0700 |
parents | 0d28b0df77ea |
children | ee751d47cf2c |
comparison
equal
deleted
inserted
replaced
24722:02a5618e2fbf | 24723:467a33142425 |
---|---|
169 if self._abort: | 169 if self._abort: |
170 raise util.Abort(msg) | 170 raise util.Abort(msg) |
171 self._ui.warn(_("warning: %s\n") % msg) | 171 self._ui.warn(_("warning: %s\n") % msg) |
172 self._loweredfiles.add(fl) | 172 self._loweredfiles.add(fl) |
173 self._newfiles.add(f) | 173 self._newfiles.add(f) |
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 | |
174 | 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 |
178 def __init__(self, *args, **kwargs): | 202 def __init__(self, *args, **kwargs): |