Mercurial > hg
comparison mercurial/bundle2.py @ 46372:3e91d9978bec
branchmap: update rev-branch-cache incrementally
Historically, the revision to branch mapping cache was updated on demand
and shared via bundle2 to avoid the cost of rebuilding on first use.
Use the new `register_changeset` callback and update rbc directly on
every change. Make the transfer of the bundle part redundant, but keep
it for the moment to avoid the test churn.
Over all, "hg unbundle" for large bundles is less than 1.8% slower for
different larger repositories and that seems to a reasonable trade off.
Differential Revision: https://phab.mercurial-scm.org/D9781
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 15 Jan 2021 01:58:59 +0100 |
parents | c511fef30290 |
children | 29e3e46b0a22 |
comparison
equal
deleted
inserted
replaced
46371:0903d6b9b1df | 46372:3e91d9978bec |
---|---|
2476 rbcstruct = struct.Struct(b'>III') | 2476 rbcstruct = struct.Struct(b'>III') |
2477 | 2477 |
2478 | 2478 |
2479 @parthandler(b'cache:rev-branch-cache') | 2479 @parthandler(b'cache:rev-branch-cache') |
2480 def handlerbc(op, inpart): | 2480 def handlerbc(op, inpart): |
2481 """receive a rev-branch-cache payload and update the local cache | 2481 """Legacy part, ignored for compatibility with bundles from or |
2482 | 2482 for Mercurial before 5.7. Newer Mercurial computes the cache |
2483 The payload is a series of data related to each branch | 2483 efficiently enough during unbundling that the additional transfer |
2484 | 2484 is unnecessary.""" |
2485 1) branch name length | |
2486 2) number of open heads | |
2487 3) number of closed heads | |
2488 4) open heads nodes | |
2489 5) closed heads nodes | |
2490 """ | |
2491 total = 0 | |
2492 rawheader = inpart.read(rbcstruct.size) | |
2493 cache = op.repo.revbranchcache() | |
2494 cl = op.repo.unfiltered().changelog | |
2495 while rawheader: | |
2496 header = rbcstruct.unpack(rawheader) | |
2497 total += header[1] + header[2] | |
2498 utf8branch = inpart.read(header[0]) | |
2499 branch = encoding.tolocal(utf8branch) | |
2500 for x in pycompat.xrange(header[1]): | |
2501 node = inpart.read(20) | |
2502 rev = cl.rev(node) | |
2503 cache.setdata(branch, rev, node, False) | |
2504 for x in pycompat.xrange(header[2]): | |
2505 node = inpart.read(20) | |
2506 rev = cl.rev(node) | |
2507 cache.setdata(branch, rev, node, True) | |
2508 rawheader = inpart.read(rbcstruct.size) | |
2509 cache.write() | |
2510 | 2485 |
2511 | 2486 |
2512 @parthandler(b'pushvars') | 2487 @parthandler(b'pushvars') |
2513 def bundle2getvars(op, part): | 2488 def bundle2getvars(op, part): |
2514 '''unbundle a bundle2 containing shellvars on the server''' | 2489 '''unbundle a bundle2 containing shellvars on the server''' |