svn: Fix parsing empty "svn:mergeinfo" value

This commit is contained in:
Konstantin Kolosovsky
2018-07-12 22:00:47 +03:00
parent 9d9b1ae513
commit fb27a378b5
2 changed files with 11 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.svn.mergeinfo
import org.jetbrains.idea.svn.api.ErrorCode.MERGE_INFO_PARSE_ERROR
@@ -8,7 +8,8 @@ data class MergeRangeList(val ranges: Set<MergeRange>) {
companion object {
@JvmStatic
@Throws(SvnBindException::class)
fun parseMergeInfo(value: String): Map<String, MergeRangeList> = value.lineSequence().map { parseLine(it) }.toMap()
fun parseMergeInfo(value: String): Map<String, MergeRangeList> = if (value.isEmpty()) emptyMap()
else value.lineSequence().map { parseLine(it) }.toMap()
@Throws(SvnBindException::class)
fun parseRange(value: String): MergeRange {

View File

@@ -1,7 +1,8 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.svn.mergeinfo
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
class MergeRangeListTest {
@@ -27,6 +28,12 @@ class MergeRangeListTest {
assertEquals(expected, mergeInfo)
}
@Test
fun `parse empty merge info`() {
val mergeInfo = MergeRangeList.parseMergeInfo("")
assertTrue(mergeInfo.isEmpty())
}
private fun assertRange(value: String, start: Long, endInclusive: Long, isInheritable: Boolean = true) = assertEquals(
MergeRange(start, endInclusive, isInheritable), MergeRangeList.parseRange(value))
}