Show More
@@ -4205,13 +4205,22 b' def perfbranchmap(ui, repo, *filternames' | |||
|
4205 | 4205 | # add unfiltered |
|
4206 | 4206 | allfilters.append(None) |
|
4207 | 4207 | |
|
4208 | if util.safehasattr(branchmap.branchcache, 'fromfile'): | |
|
4208 | old_branch_cache_from_file = None | |
|
4209 | branchcacheread = None | |
|
4210 | if util.safehasattr(branchmap, 'branch_cache_from_file'): | |
|
4211 | old_branch_cache_from_file = branchmap.branch_cache_from_file | |
|
4212 | branchmap.branch_cache_from_file = lambda *args: None | |
|
4213 | elif util.safehasattr(branchmap.branchcache, 'fromfile'): | |
|
4209 | 4214 | branchcacheread = safeattrsetter(branchmap.branchcache, b'fromfile') |
|
4210 | 4215 | branchcacheread.set(classmethod(lambda *args: None)) |
|
4211 | 4216 | else: |
|
4212 | 4217 | # older versions |
|
4213 | 4218 | branchcacheread = safeattrsetter(branchmap, b'read') |
|
4214 | 4219 | branchcacheread.set(lambda *args: None) |
|
4220 | if util.safehasattr(branchmap, '_LocalBranchCache'): | |
|
4221 | branchcachewrite = safeattrsetter(branchmap._LocalBranchCache, b'write') | |
|
4222 | branchcachewrite.set(lambda *args: None) | |
|
4223 | else: | |
|
4215 | 4224 | branchcachewrite = safeattrsetter(branchmap.branchcache, b'write') |
|
4216 | 4225 | branchcachewrite.set(lambda *args: None) |
|
4217 | 4226 | try: |
@@ -4221,6 +4230,9 b' def perfbranchmap(ui, repo, *filternames' | |||
|
4221 | 4230 | printname = b'unfiltered' |
|
4222 | 4231 | timer(getbranchmap(name), title=printname) |
|
4223 | 4232 | finally: |
|
4233 | if old_branch_cache_from_file is not None: | |
|
4234 | branchmap.branch_cache_from_file = old_branch_cache_from_file | |
|
4235 | if branchcacheread is not None: | |
|
4224 | 4236 | branchcacheread.restore() |
|
4225 | 4237 | branchcachewrite.restore() |
|
4226 | 4238 | fm.end() |
@@ -4381,10 +4393,10 b' def perfbranchmapload(ui, repo, filter=b' | |||
|
4381 | 4393 | |
|
4382 | 4394 | repo.branchmap() # make sure we have a relevant, up to date branchmap |
|
4383 | 4395 | |
|
4384 | try: | |
|
4385 | fromfile = branchmap.branchcache.fromfile | |
|
4386 | except AttributeError: | |
|
4387 | # older versions | |
|
4396 | fromfile = getattr(branchmap, 'branch_cache_from_file', None) | |
|
4397 | if fromfile is None: | |
|
4398 | fromfile = getattr(branchmap.branchcache, 'fromfile', None) | |
|
4399 | if fromfile is None: | |
|
4388 | 4400 | fromfile = branchmap.read |
|
4389 | 4401 | |
|
4390 | 4402 | currentfilter = filter |
@@ -100,7 +100,7 b' class BranchMapCache:' | |||
|
100 | 100 | bcache = self._per_filter.get(filtername) |
|
101 | 101 | if bcache is None or not bcache.validfor(repo): |
|
102 | 102 | # cache object missing or cache object stale? Read from disk |
|
103 |
bcache = branch |
|
|
103 | bcache = branch_cache_from_file(repo) | |
|
104 | 104 | |
|
105 | 105 | revs = [] |
|
106 | 106 | if bcache is None: |
@@ -116,7 +116,7 b' class BranchMapCache:' | |||
|
116 | 116 | revs.extend(r for r in extrarevs if r <= bcache.tiprev) |
|
117 | 117 | else: |
|
118 | 118 | # nothing to fall back on, start empty. |
|
119 | bcache = branchcache(repo) | |
|
119 | bcache = new_branch_cache(repo) | |
|
120 | 120 | |
|
121 | 121 | revs.extend(cl.revs(start=bcache.tiprev + 1)) |
|
122 | 122 | if revs: |
@@ -147,7 +147,7 b' class BranchMapCache:' | |||
|
147 | 147 | |
|
148 | 148 | if rbheads: |
|
149 | 149 | rtiprev = max((int(clrev(node)) for node in rbheads)) |
|
150 | cache = branchcache( | |
|
150 | cache = new_branch_cache( | |
|
151 | 151 | repo, |
|
152 | 152 | remotebranchmap, |
|
153 | 153 | repo[rtiprev].node(), |
@@ -199,21 +199,6 b' class _BaseBranchCache:' | |||
|
199 | 199 | |
|
200 | 200 | This cache is used to avoid costly computations to determine all the |
|
201 | 201 | branch heads of a repo. |
|
202 | ||
|
203 | The cache is serialized on disk in the following format: | |
|
204 | ||
|
205 | <tip hex node> <tip rev number> [optional filtered repo hex hash] | |
|
206 | <branch head hex node> <open/closed state> <branch name> | |
|
207 | <branch head hex node> <open/closed state> <branch name> | |
|
208 | ... | |
|
209 | ||
|
210 | The first line is used to check if the cache is still valid. If the | |
|
211 | branch cache is for a filtered repo view, an optional third hash is | |
|
212 | included that hashes the hashes of all filtered and obsolete revisions. | |
|
213 | ||
|
214 | The open/closed state is represented by a single letter 'o' or 'c'. | |
|
215 | This field can be used to avoid changelog reads when determining if a | |
|
216 | branch head closes a branch or not. | |
|
217 | 202 | """ |
|
218 | 203 | |
|
219 | 204 | def __init__( |
@@ -420,10 +405,10 b' STATE_INHERITED = 2' | |||
|
420 | 405 | STATE_DIRTY = 3 |
|
421 | 406 | |
|
422 | 407 | |
|
423 |
class |
|
|
424 |
""" |
|
|
408 | class _LocalBranchCache(_BaseBranchCache): | |
|
409 | """base class of branch-map info for a local repo or repoview""" | |
|
425 | 410 | |
|
426 |
_base_filename = |
|
|
411 | _base_filename = None | |
|
427 | 412 | |
|
428 | 413 | def __init__( |
|
429 | 414 | self, |
@@ -560,6 +545,7 b' class branchcache(_BaseBranchCache):' | |||
|
560 | 545 | def _filename(cls, repo): |
|
561 | 546 | """name of a branchcache file for a given repo or repoview""" |
|
562 | 547 | filename = cls._base_filename |
|
548 | assert filename is not None | |
|
563 | 549 | if repo.filtername: |
|
564 | 550 | filename = b'%s-%s' % (filename, repo.filtername) |
|
565 | 551 | return filename |
@@ -741,6 +727,38 b' class branchcache(_BaseBranchCache):' | |||
|
741 | 727 | self.write(repo) |
|
742 | 728 | |
|
743 | 729 | |
|
730 | def branch_cache_from_file(repo) -> Optional[_LocalBranchCache]: | |
|
731 | """Build a branch cache from on-disk data if possible""" | |
|
732 | return BranchCacheV2.fromfile(repo) | |
|
733 | ||
|
734 | ||
|
735 | def new_branch_cache(repo, *args, **kwargs): | |
|
736 | """Build a new branch cache from argument""" | |
|
737 | return BranchCacheV2(repo, *args, **kwargs) | |
|
738 | ||
|
739 | ||
|
740 | class BranchCacheV2(_LocalBranchCache): | |
|
741 | """a branch cache using version 2 of the format on disk | |
|
742 | ||
|
743 | The cache is serialized on disk in the following format: | |
|
744 | ||
|
745 | <tip hex node> <tip rev number> [optional filtered repo hex hash] | |
|
746 | <branch head hex node> <open/closed state> <branch name> | |
|
747 | <branch head hex node> <open/closed state> <branch name> | |
|
748 | ... | |
|
749 | ||
|
750 | The first line is used to check if the cache is still valid. If the | |
|
751 | branch cache is for a filtered repo view, an optional third hash is | |
|
752 | included that hashes the hashes of all filtered and obsolete revisions. | |
|
753 | ||
|
754 | The open/closed state is represented by a single letter 'o' or 'c'. | |
|
755 | This field can be used to avoid changelog reads when determining if a | |
|
756 | branch head closes a branch or not. | |
|
757 | """ | |
|
758 | ||
|
759 | _base_filename = b"branch2" | |
|
760 | ||
|
761 | ||
|
744 | 762 | class remotebranchcache(_BaseBranchCache): |
|
745 | 763 | """Branchmap info for a remote connection, should not write locally""" |
|
746 | 764 |
General Comments 0
You need to be logged in to leave comments.
Login now