Mercurial > jhg
changeset 209:9ce3b26798c4
Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 28 Apr 2011 03:44:45 +0200 |
parents | ef8eba4aa215 |
children | 6a2481866491 |
files | design.txt src/org/tmatesoft/hg/internal/RepositoryComparator.java |
diffstat | 2 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/design.txt Thu Apr 28 03:17:50 2011 +0200 +++ b/design.txt Thu Apr 28 03:44:45 2011 +0200 @@ -67,6 +67,9 @@ -cancellation and progress support -timestamp check for revlog to recognize external changes +-HgDate or any other better access to time info +-(low) RepositoryComparator#calculateMissingBranches may query branches for the same head more than once + (when there are few heads that end up with common nodes). e.g hg4j revision 7 against remote hg4j revision 206 >>>> Effective file read/data access ReadOperation, Revlog does: repo.getFileSystem().run(this.file, new ReadOperation(), long start=0, long end = -1)
--- a/src/org/tmatesoft/hg/internal/RepositoryComparator.java Thu Apr 28 03:17:50 2011 +0200 +++ b/src/org/tmatesoft/hg/internal/RepositoryComparator.java Thu Apr 28 03:44:45 2011 +0200 @@ -249,11 +249,26 @@ boolean hasP1 = !NULL.equals(rb.p1), hasP2 = !NULL.equals(rb.p2); if (hasP1 && !localRepo.knownNode(rb.p1)) { toQuery.add(rb.p1); - head2chain.put(rb.p1, chainElement.p1 = new BranchChain(rb.p1)); + // we might have seen parent node already, and recorded it as a branch chain + // we shall reuse existing BC to get it completely initializer (head2chain map + // on second put with the same key would leave first BC uninitialized. + + // It seems there's no reason to be affraid (XXX although shall double-check) + // that BC's chain would get corrupt (its p1 and p2 fields assigned twice with different values) + // as parents are always the same (and likely, BC that is common would be the last unknown) + BranchChain bc = head2chain.get(rb.p1); + if (bc == null) { + head2chain.put(rb.p1, bc = new BranchChain(rb.p1)); + } + chainElement.p2 = bc; } if (hasP2 && !localRepo.knownNode(rb.p2)) { toQuery.add(rb.p2); - head2chain.put(rb.p2, chainElement.p2 = new BranchChain(rb.p2)); + BranchChain bc = head2chain.get(rb.p2); + if (bc == null) { + head2chain.put(rb.p2, bc = new BranchChain(rb.p2)); + } + chainElement.p2 = bc; } if (!hasP1 && !hasP2) { // special case, when we do incoming against blank repository, chainElement.branchRoot