contrib/perf.py
changeset 51493 82c1a388e86a
parent 51450 3aba79ce52a9
child 51519 ec640dc9cebd
equal deleted inserted replaced
51492:2e8a88e5809f 51493:82c1a388e86a
  4301         repoview.filtertable[b'__perf_branchmap_update_target'] = targetfilter
  4301         repoview.filtertable[b'__perf_branchmap_update_target'] = targetfilter
  4302 
  4302 
  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         bcache = repo.branchmap()
       
  4307         copy_method = 'copy'
       
  4308 
  4306         copy_base_kwargs = copy_base_kwargs = {}
  4309         copy_base_kwargs = copy_base_kwargs = {}
  4307         if 'repo' in getargspec(repo.branchmap().copy).args:
  4310         if hasattr(bcache, 'copy'):
       
  4311             if 'repo' in getargspec(bcache.copy).args:
       
  4312                 copy_base_kwargs = {"repo": baserepo}
       
  4313                 copy_target_kwargs = {"repo": targetrepo}
       
  4314         else:
       
  4315             copy_method = 'inherit_for'
  4308             copy_base_kwargs = {"repo": baserepo}
  4316             copy_base_kwargs = {"repo": baserepo}
  4309             copy_target_kwargs = {"repo": targetrepo}
  4317             copy_target_kwargs = {"repo": targetrepo}
  4310 
  4318 
  4311         # try to find an existing branchmap to reuse
  4319         # try to find an existing branchmap to reuse
  4312         subsettable = getbranchmapsubsettable()
  4320         subsettable = getbranchmapsubsettable()
  4314         while candidatefilter is not None:
  4322         while candidatefilter is not None:
  4315             candidatebm = repo.filtered(candidatefilter).branchmap()
  4323             candidatebm = repo.filtered(candidatefilter).branchmap()
  4316             if candidatebm.validfor(baserepo):
  4324             if candidatebm.validfor(baserepo):
  4317                 filtered = repoview.filterrevs(repo, candidatefilter)
  4325                 filtered = repoview.filterrevs(repo, candidatefilter)
  4318                 missing = [r for r in allbaserevs if r in filtered]
  4326                 missing = [r for r in allbaserevs if r in filtered]
  4319                 base = candidatebm.copy(**copy_base_kwargs)
  4327                 base = getattr(candidatebm, copy_method)(**copy_base_kwargs)
  4320                 base.update(baserepo, missing)
  4328                 base.update(baserepo, missing)
  4321                 break
  4329                 break
  4322             candidatefilter = subsettable.get(candidatefilter)
  4330             candidatefilter = subsettable.get(candidatefilter)
  4323         else:
  4331         else:
  4324             # no suitable subset where found
  4332             # no suitable subset where found
  4325             base = branchmap.branchcache()
  4333             base = branchmap.branchcache()
  4326             base.update(baserepo, allbaserevs)
  4334             base.update(baserepo, allbaserevs)
  4327 
  4335 
  4328         def setup():
  4336         def setup():
  4329             x[0] = base.copy(**copy_target_kwargs)
  4337             x[0] = getattr(base, copy_method)(**copy_target_kwargs)
  4330             if clearcaches:
  4338             if clearcaches:
  4331                 unfi._revbranchcache = None
  4339                 unfi._revbranchcache = None
  4332                 clearchangelog(repo)
  4340                 clearchangelog(repo)
  4333 
  4341 
  4334         def bench():
  4342         def bench():