Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 17740:e6067bec18da
branchcache: fetch source branchcache during clone (issue3378)
Recomputing branch cache on clone may be expensive,
therefore if possible we fetch it along with the data.
- If the clone is performed by copying, we just copy branchcache file.
- If we localrepo.clone and streaming then we follow the procedure:
1. Fetch branchmap from the remote
2. Fetch the actual data.
3. Find the latest rev within branch heads (tip at the time of
branchmap fetch)
4. Update the cache for the revs in [remotetip+1, tip]
This way we ensure that the branchcache is correct even in case
of races with commits.
author | Tomasz Kleczek <tomasz.kleczek@fb.com> |
---|---|
date | Wed, 03 Oct 2012 13:19:53 -0700 |
parents | 1adba7ff4d26 |
children | c547e1acc37c |
comparison
equal
deleted
inserted
replaced
17739:5b08e8b7ab00 | 17740:e6067bec18da |
---|---|
2470 return dh + 1 | 2470 return dh + 1 |
2471 | 2471 |
2472 def stream_in(self, remote, requirements): | 2472 def stream_in(self, remote, requirements): |
2473 lock = self.lock() | 2473 lock = self.lock() |
2474 try: | 2474 try: |
2475 # Save remote branchmap. We will use it later | |
2476 # to speed up branchcache creation | |
2477 rbranchmap = None | |
2478 if remote.capable("branchmap"): | |
2479 rbranchmap = remote.branchmap() | |
2480 | |
2475 fp = remote.stream_out() | 2481 fp = remote.stream_out() |
2476 l = fp.readline() | 2482 l = fp.readline() |
2477 try: | 2483 try: |
2478 resp = int(l) | 2484 resp = int(l) |
2479 except ValueError: | 2485 except ValueError: |
2530 # requirements from the streamed-in repository | 2536 # requirements from the streamed-in repository |
2531 requirements.update(set(self.requirements) - self.supportedformats) | 2537 requirements.update(set(self.requirements) - self.supportedformats) |
2532 self._applyrequirements(requirements) | 2538 self._applyrequirements(requirements) |
2533 self._writerequirements() | 2539 self._writerequirements() |
2534 | 2540 |
2541 if rbranchmap: | |
2542 rbheads = [] | |
2543 for bheads in rbranchmap.itervalues(): | |
2544 rbheads.extend(bheads) | |
2545 | |
2546 self.branchcache = rbranchmap | |
2547 if rbheads: | |
2548 rtiprev = max((int(self.changelog.rev(node)) | |
2549 for node in rbheads)) | |
2550 self._writebranchcache(self.branchcache, | |
2551 self[rtiprev].node(), rtiprev) | |
2535 self.invalidate() | 2552 self.invalidate() |
2536 return len(self.heads()) + 1 | 2553 return len(self.heads()) + 1 |
2537 finally: | 2554 finally: |
2538 lock.release() | 2555 lock.release() |
2539 | 2556 |