improved (removed) dependencies

This commit is contained in:
Sergey Chernov 2023-04-06 15:31:48 +01:00
parent 485afbbace
commit 86d24c6a9a
4 changed files with 35 additions and 57 deletions

View File

@ -42,12 +42,12 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("dev.gitlive:kotlin-diff-utils:4.1.4")
implementation("net.sergeych:mp_stools:[1.3.4,)")
// implementation("dev.gitlive:kotlin-diff-utils:4.1.4")
}
}
val commonTest by getting {
dependencies {
implementation("net.sergeych:mp_stools:[1.3.4,)")
implementation(kotlin("test"))
}
}

View File

@ -52,11 +52,6 @@
"@jridgewell/resolve-uri" "3.1.0"
"@jridgewell/sourcemap-codec" "1.4.14"
"@js-joda/core@3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-3.2.0.tgz#3e61e21b7b2b8a6be746df1335cf91d70db2a273"
integrity sha512-PMqgJ0sw5B7FKb2d5bWYIoxjri+QlW/Pys7+Rw82jSH0QN3rB05jZ/VrrsUdh1w4+i2kw9JOejXGq/KhDOX7Kg==
"@socket.io/component-emitter@~3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz#96116f2a912e0c02817345b3c10751069920d553"
@ -603,14 +598,6 @@ dom-serialize@^2.2.1:
extend "^3.0.0"
void-elements "^2.0.0"
dukat@0.5.8-rc.4:
version "0.5.8-rc.4"
resolved "https://registry.yarnpkg.com/dukat/-/dukat-0.5.8-rc.4.tgz#90384dcb50b14c26f0e99dae92b2dea44f5fce21"
integrity sha512-ZnMt6DGBjlVgK2uQamXfd7uP/AxH7RqI0BL9GLrrJb2gKdDxvJChWy+M9AQEaL+7/6TmxzJxFOsRiInY9oGWTA==
dependencies:
google-protobuf "3.12.2"
typescript "3.9.5"
ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
@ -875,11 +862,6 @@ glob@^7.1.3, glob@^7.1.7:
once "^1.3.0"
path-is-absolute "^1.0.0"
google-protobuf@3.12.2:
version "3.12.2"
resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.12.2.tgz#50ce9f9b6281235724eb243d6a83e969a2176e53"
integrity sha512-4CZhpuRr1d6HjlyrxoXoocoGFnRYgKULgMtikMddA9ztRyYR59Aondv2FioyxWVamRo0rF2XpYawkTCBEQOSkA==
graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9:
version "4.2.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
@ -1731,11 +1713,6 @@ type-is@~1.6.18:
media-typer "0.3.0"
mime-types "~2.1.24"
typescript@3.9.5:
version "3.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36"
integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==
ua-parser-js@^0.7.30:
version "0.7.34"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.34.tgz#afb439e2e3e394bdc90080acb661a39c685b67d7"

View File

@ -5,7 +5,6 @@ import dev.gitlive.difflib.patch.AbstractDelta
import dev.gitlive.difflib.patch.ChangeDelta
import dev.gitlive.difflib.patch.DeleteDelta
import dev.gitlive.difflib.patch.InsertDelta
import net.sergeych.sprintf.sprintf
/**
* Merge result. This version does not report (yet) conflicts, just merges it all. See also [blocks] for
@ -43,15 +42,6 @@ class MergeResult<T>(
}
}
fun toTrace(source: List<T>): String {
val r = StringBuilder()
r.append(merged.indices.joinToString("") { "%3d".sprintf(it) } + "\n")
r.append(merged.joinToString("") { "%3s".sprintf(it) } + "\n")
r.append("---- source ----\n")
r.append(source.joinToString("") { "%3s".sprintf(it) } + "\n")
r.append(sourceIndices.joinToString("") { "%3s".sprintf(it) } + "\n")
return r.toString()
}
}
/**
@ -102,23 +92,23 @@ private class Merge3<T>(
if (showDebug) println(f())
}
private fun trace() {
debug { result.indices.joinToString("") { "%3d".sprintf(it) } }
debug { result.joinToString("") { "%3s".sprintf(it.toString()) } }
debug {
changeCount.joinToString("") {
when (it) {
1 -> " *"
0 -> " ."
2 -> " !"
else -> " !$it"
}
}
}
debug { reindex.joinToString("") { if (it < 0) " x" else "%3d".sprintf(it) } }
}
// private fun trace() {
//
// debug { result.indices.joinToString("") { "%3d".sprintf(it) } }
// debug { result.joinToString("") { "%3s".sprintf(it.toString()) } }
// debug {
// changeCount.joinToString("") {
// when (it) {
// 1 -> " *"
// 0 -> " ."
// 2 -> " !"
// else -> " !$it"
// }
// }
// }
// debug { reindex.joinToString("") { if (it < 0) " x" else "%3d".sprintf(it) } }
//
// }
private fun findPosition(sourcePosition: Int): Int {
var position = if (sourcePosition < reindex.size) reindex[sourcePosition] else reindex.last() + 1
@ -184,7 +174,7 @@ private class Merge3<T>(
is ChangeDelta<T> -> {
deleteAt(delta.source.position, delta.source.size())
trace()
// trace()
insertAt(delta.source.position, delta.target.lines)
}
@ -197,7 +187,7 @@ private class Merge3<T>(
}
}
debug { "Applied: $delta, result:" }
trace()
// trace()
}
@ -208,8 +198,7 @@ private class Merge3<T>(
debug { "dA: $dA" }
debug { "dB: $dB" }
trace()
// trace()
debug { "adding first set" }
for (d in dA) {
@ -261,7 +250,7 @@ private class Merge3<T>(
}
else -> {
trace()
// trace()
throw RuntimeException("internal error: invalud change counter @$index:$count")
}
}

View File

@ -1,10 +1,22 @@
import net.sergeych.merge3.MergeResult
import net.sergeych.merge3.merge3
import net.sergeych.mp_logger.Log
import net.sergeych.sprintf.sprintf
import kotlin.test.Test
import kotlin.test.assertEquals
val List<Char>.str: String get() = joinToString("")
fun <T>MergeResult<T>.toTrace(source: List<T>): String {
val r = StringBuilder()
r.append(merged.indices.joinToString("") { "%3d".sprintf(it) } + "\n")
r.append(merged.joinToString("") { "%3s".sprintf(it) } + "\n")
r.append("---- source ----\n")
r.append(source.joinToString("") { "%3s".sprintf(it) } + "\n")
r.append(sourceIndices.joinToString("") { "%3s".sprintf(it) } + "\n")
return r.toString()
}
class BasicTest {
@Test
fun testMergeNoConflicts() {