# HG changeset patch # User Artem Tikhomirov # Date 1303955085 -7200 # Node ID 9ce3b26798c4320b8585988437ff798773f8cd0a # Parent ef8eba4aa2157b33e179fe9f52d5373251d9faf3 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements diff -r ef8eba4aa215 -r 9ce3b26798c4 design.txt --- 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) diff -r ef8eba4aa215 -r 9ce3b26798c4 src/org/tmatesoft/hg/internal/RepositoryComparator.java --- 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