Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 41581:c795c462b1d6
branchmap: add some clarifications and clean up flow
- Remove indentation where it is not needed.
- Swap the subset test branches to follow along logically and put the 'empty'
case last.
Differential Revision: https://phab.mercurial-scm.org/D5637
author | Martijn Pieters <mj@octobus.net> |
---|---|
date | Mon, 21 Jan 2019 17:41:59 +0000 |
parents | eb7ce452e0fb |
children | 328ca3b9e545 |
comparison
equal
deleted
inserted
replaced
41580:eb7ce452e0fb | 41581:c795c462b1d6 |
---|---|
42 'visible': 'served', | 42 'visible': 'served', |
43 'served': 'immutable', | 43 'served': 'immutable', |
44 'immutable': 'base'} | 44 'immutable': 'base'} |
45 | 45 |
46 def updatecache(repo): | 46 def updatecache(repo): |
47 """Update the cache for the given filtered view on a repository""" | |
48 # This can trigger updates for the caches for subsets of the filtered | |
49 # view, e.g. when there is no cache for this filtered view or the cache | |
50 # is stale. | |
51 | |
47 cl = repo.changelog | 52 cl = repo.changelog |
48 filtername = repo.filtername | 53 filtername = repo.filtername |
49 bcache = repo._branchcaches.get(filtername) | 54 bcache = repo._branchcaches.get(filtername) |
55 if bcache is None or not bcache.validfor(repo): | |
56 # cache object missing or cache object stale? Read from disk | |
57 bcache = branchcache.fromfile(repo) | |
50 | 58 |
51 revs = [] | 59 revs = [] |
52 if bcache is None or not bcache.validfor(repo): | 60 if bcache is None: |
53 bcache = branchcache.fromfile(repo) | 61 # no (fresh) cache available anymore, perhaps we can re-use |
54 if bcache is None: | 62 # the cache for a subset, then extend that to add info on missing |
55 subsetname = subsettable.get(filtername) | 63 # revisions. |
56 if subsetname is None: | 64 subsetname = subsettable.get(filtername) |
57 bcache = branchcache() | 65 if subsetname is not None: |
58 else: | 66 subset = repo.filtered(subsetname) |
59 subset = repo.filtered(subsetname) | 67 bcache = subset.branchmap().copy() |
60 bcache = subset.branchmap().copy() | 68 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs |
61 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs | 69 revs.extend(r for r in extrarevs if r <= bcache.tiprev) |
62 revs.extend(r for r in extrarevs if r <= bcache.tiprev) | 70 else: |
71 # nothing to fall back on, start empty. | |
72 bcache = branchcache() | |
73 | |
63 revs.extend(cl.revs(start=bcache.tiprev + 1)) | 74 revs.extend(cl.revs(start=bcache.tiprev + 1)) |
64 if revs: | 75 if revs: |
65 bcache.update(repo, revs) | 76 bcache.update(repo, revs) |
66 | 77 |
67 assert bcache.validfor(repo), filtername | 78 assert bcache.validfor(repo), filtername |