@@ -24,9 +24,9 @@ class LinearHistory(private val baseVersionHash: String?) {
24
24
private val byVersionDistanceFromGlobalRoot = mutableMapOf<CLVersion , Int >()
25
25
26
26
/* *
27
- * Returns all versions between the [fromVersions] and a common version.
27
+ * Returns all versions between the [fromVersions] (inclusive) and a common version (inclusive) .
28
28
* The common version may be identified by [baseVersionHash].
29
- * If no [baseVersionHash] is given, the common version wile be the first version
29
+ * If no [baseVersionHash] is given, the common version will be the first version
30
30
* aka the version without a [CLVersion.baseVersion].
31
31
*
32
32
* The order also ensures three properties:
@@ -35,14 +35,14 @@ class LinearHistory(private val baseVersionHash: String?) {
35
35
* This means adding a version to the set of all versions will never change
36
36
* the order of versions that were previously in the history.
37
37
* For example, given versions 1, 2 and 3:
38
- * If 1 and 2 are ordered as (1, 2), ordering 1, 2 and 3 will never produce (2, 3 , 1).
39
- * 3 can come anywhere (respecting the topological ordering), but 2 has to come after 1.
38
+ * If 1 and 2 are ordered as (1, 2), ordering 1, 2 and x will never produce (2, x , 1).
39
+ * x can come anywhere (respecting the topological ordering), but 2 has to come after 1.
40
40
* 3. "Close versions are kept together"
41
- * Formally: A version that has only one child (ignoring) should always come before the child.
42
- * Example: 1 <- 2 <- 3 and 1 <- x, then [1, 2, 4 , 3] is not allowed,
41
+ * Formally: A version that has only one child should always come before the child.
42
+ * Example: 1 <- 2 <- 3 and 1 <- x, then [1, 2, x , 3] is not allowed,
43
43
* because 3 is the only child of 2.
44
- * Valid orders would be (1, x , 3, 4 ) and (1, x, 2, 3)
45
- * This is relevant for UnduOp and RedoOp.
44
+ * Valid orders would be (1, 2 , 3, x ) and (1, x, 2, 3)
45
+ * This is relevant for UndoOp and RedoOp.
46
46
* See UndoTest.
47
47
*/
48
48
fun load (vararg fromVersions : CLVersion ): List <CLVersion > {
@@ -128,6 +128,9 @@ class LinearHistory(private val baseVersionHash: String?) {
128
128
}
129
129
130
130
private fun CLVersion.getParents (): List <CLVersion > {
131
+ if (this .getContentHash() == baseVersionHash) {
132
+ return emptyList()
133
+ }
131
134
val ancestors = if (isMerge()) {
132
135
listOf (getMergedVersion1()!! , getMergedVersion2()!! )
133
136
} else {
0 commit comments