##// END OF EJS Templates
branchcache: pass the target repository when copying...
marmoute -
r52343:3aba79ce default
parent child Browse files
Show More
@@ -4303,6 +4303,11 b' def perfbranchmapupdate(ui, repo, base=('
4303 baserepo = repo.filtered(b'__perf_branchmap_update_base')
4303 baserepo = repo.filtered(b'__perf_branchmap_update_base')
4304 targetrepo = repo.filtered(b'__perf_branchmap_update_target')
4304 targetrepo = repo.filtered(b'__perf_branchmap_update_target')
4305
4305
4306 copy_base_kwargs = copy_base_kwargs = {}
4307 if 'repo' in getargspec(repo.branchmap().copy).args:
4308 copy_base_kwargs = {"repo": baserepo}
4309 copy_target_kwargs = {"repo": targetrepo}
4310
4306 # try to find an existing branchmap to reuse
4311 # try to find an existing branchmap to reuse
4307 subsettable = getbranchmapsubsettable()
4312 subsettable = getbranchmapsubsettable()
4308 candidatefilter = subsettable.get(None)
4313 candidatefilter = subsettable.get(None)
@@ -4311,7 +4316,7 b' def perfbranchmapupdate(ui, repo, base=('
4311 if candidatebm.validfor(baserepo):
4316 if candidatebm.validfor(baserepo):
4312 filtered = repoview.filterrevs(repo, candidatefilter)
4317 filtered = repoview.filterrevs(repo, candidatefilter)
4313 missing = [r for r in allbaserevs if r in filtered]
4318 missing = [r for r in allbaserevs if r in filtered]
4314 base = candidatebm.copy()
4319 base = candidatebm.copy(**copy_base_kwargs)
4315 base.update(baserepo, missing)
4320 base.update(baserepo, missing)
4316 break
4321 break
4317 candidatefilter = subsettable.get(candidatefilter)
4322 candidatefilter = subsettable.get(candidatefilter)
@@ -4321,7 +4326,7 b' def perfbranchmapupdate(ui, repo, base=('
4321 base.update(baserepo, allbaserevs)
4326 base.update(baserepo, allbaserevs)
4322
4327
4323 def setup():
4328 def setup():
4324 x[0] = base.copy()
4329 x[0] = base.copy(**copy_target_kwargs)
4325 if clearcaches:
4330 if clearcaches:
4326 unfi._revbranchcache = None
4331 unfi._revbranchcache = None
4327 clearchangelog(repo)
4332 clearchangelog(repo)
@@ -60,6 +60,10 b' class BranchMapCache:'
60 def __getitem__(self, repo):
60 def __getitem__(self, repo):
61 self.updatecache(repo)
61 self.updatecache(repo)
62 bcache = self._per_filter[repo.filtername]
62 bcache = self._per_filter[repo.filtername]
63 assert bcache._repo.filtername == repo.filtername, (
64 bcache._repo.filtername,
65 repo.filtername,
66 )
63 return bcache
67 return bcache
64
68
65 def update_disk(self, repo):
69 def update_disk(self, repo):
@@ -76,6 +80,10 b' class BranchMapCache:'
76 """
80 """
77 self.updatecache(repo)
81 self.updatecache(repo)
78 bcache = self._per_filter[repo.filtername]
82 bcache = self._per_filter[repo.filtername]
83 assert bcache._repo.filtername == repo.filtername, (
84 bcache._repo.filtername,
85 repo.filtername,
86 )
79 bcache.write(repo)
87 bcache.write(repo)
80
88
81 def updatecache(self, repo):
89 def updatecache(self, repo):
@@ -99,7 +107,7 b' class BranchMapCache:'
99 subsetname = subsettable.get(filtername)
107 subsetname = subsettable.get(filtername)
100 if subsetname is not None:
108 if subsetname is not None:
101 subset = repo.filtered(subsetname)
109 subset = repo.filtered(subsetname)
102 bcache = self[subset].copy()
110 bcache = self[subset].copy(repo)
103 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
111 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
104 revs.extend(r for r in extrarevs if r <= bcache.tiprev)
112 revs.extend(r for r in extrarevs if r <= bcache.tiprev)
105 else:
113 else:
@@ -148,7 +156,7 b' class BranchMapCache:'
148 for candidate in (b'base', b'immutable', b'served'):
156 for candidate in (b'base', b'immutable', b'served'):
149 rview = repo.filtered(candidate)
157 rview = repo.filtered(candidate)
150 if cache.validfor(rview):
158 if cache.validfor(rview):
151 self._per_filter[candidate] = cache
159 cache = self._per_filter[candidate] = cache.copy(rview)
152 cache.write(rview)
160 cache.write(rview)
153 return
161 return
154
162
@@ -415,10 +423,10 b' class branchcache:'
415 self._verifyall()
423 self._verifyall()
416 return self._entries.values()
424 return self._entries.values()
417
425
418 def copy(self):
426 def copy(self, repo):
419 """return an deep copy of the branchcache object"""
427 """return an deep copy of the branchcache object"""
420 return type(self)(
428 return type(self)(
421 self._repo,
429 repo,
422 self._entries,
430 self._entries,
423 self.tipnode,
431 self.tipnode,
424 self.tiprev,
432 self.tiprev,
@@ -427,6 +435,10 b' class branchcache:'
427 )
435 )
428
436
429 def write(self, repo):
437 def write(self, repo):
438 assert self._repo.filtername == repo.filtername, (
439 self._repo.filtername,
440 repo.filtername,
441 )
430 tr = repo.currenttransaction()
442 tr = repo.currenttransaction()
431 if not getattr(tr, 'finalized', True):
443 if not getattr(tr, 'finalized', True):
432 # Avoid premature writing.
444 # Avoid premature writing.
@@ -471,6 +483,10 b' class branchcache:'
471 missing heads, and a generator of nodes that are strictly a superset of
483 missing heads, and a generator of nodes that are strictly a superset of
472 heads missing, this function updates self to be correct.
484 heads missing, this function updates self to be correct.
473 """
485 """
486 assert self._repo.filtername == repo.filtername, (
487 self._repo.filtername,
488 repo.filtername,
489 )
474 starttime = util.timer()
490 starttime = util.timer()
475 cl = repo.changelog
491 cl = repo.changelog
476 # collect new branch entries
492 # collect new branch entries
General Comments 0
You need to be logged in to leave comments. Login now