comparison src/org/tmatesoft/hg/internal/RepositoryComparator.java @ 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 1bf0a5af2d5d
children 6a2481866491
comparison
equal deleted inserted replaced
208:ef8eba4aa215 209:9ce3b26798c4
247 chainElement.branchRoot = rb.root; 247 chainElement.branchRoot = rb.root;
248 // dig deeper in the history, if necessary 248 // dig deeper in the history, if necessary
249 boolean hasP1 = !NULL.equals(rb.p1), hasP2 = !NULL.equals(rb.p2); 249 boolean hasP1 = !NULL.equals(rb.p1), hasP2 = !NULL.equals(rb.p2);
250 if (hasP1 && !localRepo.knownNode(rb.p1)) { 250 if (hasP1 && !localRepo.knownNode(rb.p1)) {
251 toQuery.add(rb.p1); 251 toQuery.add(rb.p1);
252 head2chain.put(rb.p1, chainElement.p1 = new BranchChain(rb.p1)); 252 // we might have seen parent node already, and recorded it as a branch chain
253 // we shall reuse existing BC to get it completely initializer (head2chain map
254 // on second put with the same key would leave first BC uninitialized.
255
256 // It seems there's no reason to be affraid (XXX although shall double-check)
257 // that BC's chain would get corrupt (its p1 and p2 fields assigned twice with different values)
258 // as parents are always the same (and likely, BC that is common would be the last unknown)
259 BranchChain bc = head2chain.get(rb.p1);
260 if (bc == null) {
261 head2chain.put(rb.p1, bc = new BranchChain(rb.p1));
262 }
263 chainElement.p2 = bc;
253 } 264 }
254 if (hasP2 && !localRepo.knownNode(rb.p2)) { 265 if (hasP2 && !localRepo.knownNode(rb.p2)) {
255 toQuery.add(rb.p2); 266 toQuery.add(rb.p2);
256 head2chain.put(rb.p2, chainElement.p2 = new BranchChain(rb.p2)); 267 BranchChain bc = head2chain.get(rb.p2);
268 if (bc == null) {
269 head2chain.put(rb.p2, bc = new BranchChain(rb.p2));
270 }
271 chainElement.p2 = bc;
257 } 272 }
258 if (!hasP1 && !hasP2) { 273 if (!hasP1 && !hasP2) {
259 // special case, when we do incoming against blank repository, chainElement.branchRoot 274 // special case, when we do incoming against blank repository, chainElement.branchRoot
260 // is first unknown element (revision 0). We need to add another fake BranchChain 275 // is first unknown element (revision 0). We need to add another fake BranchChain
261 // to fill the promise that terminal BranchChain has branchRoot that is known both locally and remotely 276 // to fill the promise that terminal BranchChain has branchRoot that is known both locally and remotely