Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgParentChildMap.java @ 645:14dac192aa26
Push: phase2 - upload bundle with changes to remote server
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 20 Jun 2013 19:15:09 +0200 |
| parents | 6526d8adbc0f |
| children | 3b7d51ed4c65 |
comparison
equal
deleted
inserted
replaced
| 644:1deea2f33218 | 645:14dac192aa26 |
|---|---|
| 18 | 18 |
| 19 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 19 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
| 20 | 20 |
| 21 import java.util.Arrays; | 21 import java.util.Arrays; |
| 22 import java.util.Collection; | 22 import java.util.Collection; |
| 23 import java.util.Collections; | |
| 23 import java.util.HashSet; | 24 import java.util.HashSet; |
| 24 import java.util.LinkedList; | 25 import java.util.LinkedList; |
| 25 import java.util.List; | 26 import java.util.List; |
| 26 | 27 |
| 27 import org.tmatesoft.hg.core.Nodeid; | 28 import org.tmatesoft.hg.core.Nodeid; |
| 54 * @author Artem Tikhomirov | 55 * @author Artem Tikhomirov |
| 55 * @author TMate Software Ltd. | 56 * @author TMate Software Ltd. |
| 56 */ | 57 */ |
| 57 public final class HgParentChildMap<T extends Revlog> implements ParentInspector { | 58 public final class HgParentChildMap<T extends Revlog> implements ParentInspector { |
| 58 | 59 |
| 59 | |
| 60 private Nodeid[] sequential; // natural repository order, childrenOf rely on ordering | 60 private Nodeid[] sequential; // natural repository order, childrenOf rely on ordering |
| 61 private Nodeid[] sorted; // for binary search | 61 private Nodeid[] sorted; // for binary search |
| 62 private int[] sorted2natural; | 62 private int[] sorted2natural; |
| 63 private Nodeid[] firstParent; | 63 private Nodeid[] firstParent; |
| 64 private Nodeid[] secondParent; | 64 private Nodeid[] secondParent; |
| 178 // nodes, their parents and so on. | 178 // nodes, their parents and so on. |
| 179 | 179 |
| 180 // @return ordered collection of all children rooted at supplied nodes. Nodes shall not be descendants of each other! | 180 // @return ordered collection of all children rooted at supplied nodes. Nodes shall not be descendants of each other! |
| 181 // Nodeids shall belong to this revlog | 181 // Nodeids shall belong to this revlog |
| 182 public List<Nodeid> childrenOf(List<Nodeid> roots) { | 182 public List<Nodeid> childrenOf(List<Nodeid> roots) { |
| 183 if (roots.isEmpty()) { | |
| 184 return Collections.emptyList(); | |
| 185 } | |
| 183 HashSet<Nodeid> parents = new HashSet<Nodeid>(); | 186 HashSet<Nodeid> parents = new HashSet<Nodeid>(); |
| 184 LinkedList<Nodeid> result = new LinkedList<Nodeid>(); | 187 LinkedList<Nodeid> result = new LinkedList<Nodeid>(); |
| 185 int earliestRevision = Integer.MAX_VALUE; | 188 int earliestRevision = Integer.MAX_VALUE; |
| 186 assert sequential.length == firstParent.length && firstParent.length == secondParent.length; | 189 assert sequential.length == firstParent.length && firstParent.length == secondParent.length; |
| 187 // first, find earliest index of roots in question, as there's no sense | 190 // first, find earliest index of roots in question, as there's no sense |
| 242 return true; | 245 return true; |
| 243 } | 246 } |
| 244 } | 247 } |
| 245 return false; | 248 return false; |
| 246 } | 249 } |
| 250 | |
| 251 /** | |
| 252 * @return all revisions this map knows about | |
| 253 */ | |
| 254 public List<Nodeid> all() { | |
| 255 return Arrays.asList(sequential); | |
| 256 } | |
| 247 } | 257 } |
