Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 20032:175c6fd8cacc
subsettable: move from repoview to branchmap, the only place it's used
This is a step towards breaking an import cycle between revset and
repoview. Import cycles happened to work in Python 2 with implicit
relative imports, but breaks on Python 3 when we start using explicit
relative imports via 2to3 rewrite rules.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Wed, 06 Nov 2013 14:38:34 -0500 |
parents | a32ef044b99a |
children | b9515fb9e72a |
comparison
equal
deleted
inserted
replaced
20031:6c1adf2067bb | 20032:175c6fd8cacc |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
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 util, repoview | 10 import util |
11 | 11 |
12 def _filename(repo): | 12 def _filename(repo): |
13 """name of a branchcache file for a given repo or repoview""" | 13 """name of a branchcache file for a given repo or repoview""" |
14 filename = "cache/branchheads" | 14 filename = "cache/branchheads" |
15 if repo.filtername: | 15 if repo.filtername: |
56 partial = None | 56 partial = None |
57 return partial | 57 return partial |
58 | 58 |
59 | 59 |
60 | 60 |
61 ### Nearest subset relation | |
62 # Nearest subset of filter X is a filter Y so that: | |
63 # * Y is included in X, | |
64 # * X - Y is as small as possible. | |
65 # This create and ordering used for branchmap purpose. | |
66 # the ordering may be partial | |
67 subsettable = {None: 'visible', | |
68 'visible': 'served', | |
69 'served': 'immutable', | |
70 'immutable': 'base'} | |
71 | |
61 def updatecache(repo): | 72 def updatecache(repo): |
62 cl = repo.changelog | 73 cl = repo.changelog |
63 filtername = repo.filtername | 74 filtername = repo.filtername |
64 partial = repo._branchcaches.get(filtername) | 75 partial = repo._branchcaches.get(filtername) |
65 | 76 |
66 revs = [] | 77 revs = [] |
67 if partial is None or not partial.validfor(repo): | 78 if partial is None or not partial.validfor(repo): |
68 partial = read(repo) | 79 partial = read(repo) |
69 if partial is None: | 80 if partial is None: |
70 subsetname = repoview.subsettable.get(filtername) | 81 subsetname = subsettable.get(filtername) |
71 if subsetname is None: | 82 if subsetname is None: |
72 partial = branchcache() | 83 partial = branchcache() |
73 else: | 84 else: |
74 subset = repo.filtered(subsetname) | 85 subset = repo.filtered(subsetname) |
75 partial = subset.branchmap().copy() | 86 partial = subset.branchmap().copy() |