comparison src/org/tmatesoft/hg/repo/HgBlameFacility.java @ 561:d3c71498919c

Do not process child revisions before all possible parent paths were visited
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 27 Feb 2013 19:37:58 +0100
parents 154718ae23ed
children 6fbca6506bb5
comparison
equal deleted inserted replaced
560:52263817b998 561:d3c71498919c
78 fileParentRevs.add(NO_REVISION, NO_REVISION); 78 fileParentRevs.add(NO_REVISION, NO_REVISION);
79 for (int i = 1; i <= fileRevIndex; i++) { 79 for (int i = 1; i <= fileRevIndex; i++) {
80 df.parents(i, fileRevParents, null, null); 80 df.parents(i, fileRevParents, null, null);
81 fileParentRevs.add(fileRevParents[0], fileRevParents[1]); 81 fileParentRevs.add(fileRevParents[0], fileRevParents[1]);
82 } 82 }
83 // collect file revisions to visit, from newest to oldest 83 // collect file revisions to visit, from newest to oldest:
84 // traverse parents, starting from the given file revision
85 // this ignores all file revision made in parallel to the one of interest
84 IntVector fileRevsToVisit = new IntVector(fileRevIndex + 1, 0); 86 IntVector fileRevsToVisit = new IntVector(fileRevIndex + 1, 0);
85 LinkedList<Integer> queue = new LinkedList<Integer>(); 87 LinkedList<Integer> queue = new LinkedList<Integer>();
86 BitSet seen = new BitSet(fileRevIndex + 1); 88 BitSet seen = new BitSet(fileRevIndex + 1);
87 queue.add(fileRevIndex); 89 queue.add(fileRevIndex);
88 do { 90 do {
100 if (p2 != NO_REVISION) { 102 if (p2 != NO_REVISION) {
101 queue.addLast(p2); 103 queue.addLast(p2);
102 } 104 }
103 } while (!queue.isEmpty()); 105 } while (!queue.isEmpty());
104 FileLinesCache fileInfoCache = new FileLinesCache(df, 10); 106 FileLinesCache fileInfoCache = new FileLinesCache(df, 10);
107 // make sure no child is processed before we handled all (grand-)parents of the element
108 fileRevsToVisit.sort(false);
105 // fileRevsToVisit now { r10, r7, r6, r5, r0 } 109 // fileRevsToVisit now { r10, r7, r6, r5, r0 }
106 // and we'll iterate it from behind, e.g. old to new unless reversed 110 // and we'll iterate it from behind, e.g. old to new unless reversed
107 if (iterateOrder == HgIterateDirection.NewToOld) { 111 if (iterateOrder == HgIterateDirection.NewToOld) {
108 fileRevsToVisit.reverse(); 112 fileRevsToVisit.reverse();
109 } 113 }