diff src/org/tmatesoft/hg/repo/Revlog.java @ 308:3f40262153a4

Recognize closed branches
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 24 Sep 2011 07:29:05 +0200
parents 2f2ab5c27f41
children 09628675bcee
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/Revlog.java	Sat Sep 24 04:06:27 2011 +0200
+++ b/src/org/tmatesoft/hg/repo/Revlog.java	Sat Sep 24 07:29:05 2011 +0200
@@ -357,6 +357,23 @@
 		}
 		
 		/**
+		 * @return revisions that have supplied revision as their immediate parent
+		 */
+		public List<Nodeid> directChildren(Nodeid nid) {
+			LinkedList<Nodeid> result = new LinkedList<Nodeid>();
+			int x = Arrays.binarySearch(sorted, nid);
+			assertSortedIndex(x);
+			nid = sorted[x]; // canonical instance
+			int start = sorted2natural[x];
+			for (int i = start + 1; i < sequential.length; i++) {
+				if (nid == firstParent[i] || nid == secondParent[i]) {
+					result.add(sequential[i]);
+				}
+			}
+			return result;
+		}
+		
+		/**
 		 * @param nid possibly parent node, shall be {@link #knownNode(Nodeid) known} in this revlog.
 		 * @return <code>true</code> if there's any node in this revlog that has specified node as one of its parents. 
 		 */