@@ -121,6 +121,31 @@ class RepositoriesManager(val client: LocalModelClient) {
121
121
}
122
122
}
123
123
124
+ fun removeRepository (repository : RepositoryId ) {
125
+ store.runTransaction {
126
+ for (branchName in getBranchNames(repository)) {
127
+ putVersionHash(repository.getBranchReference(branchName), null )
128
+ }
129
+ store.put(branchListKey(repository), null )
130
+ val existingRepositories = getRepositories()
131
+ val remainingRepositories = existingRepositories - repository
132
+ store.put(REPOSITORIES_LIST_KEY , remainingRepositories.joinToString(" \n " ) { it.id })
133
+ }
134
+ }
135
+
136
+ fun removeBranches (repository : RepositoryId , branchNames : Set <String >) {
137
+ if (branchNames.isEmpty()) return
138
+ store.runTransaction {
139
+ val key = branchListKey(repository)
140
+ val existingBranches = store[key]?.lines()?.toSet() ? : emptySet()
141
+ val remainingBranches = existingBranches - branchNames
142
+ store.put(key, remainingBranches.joinToString(" \n " ))
143
+ for (branchName in branchNames) {
144
+ putVersionHash(repository.getBranchReference(branchName), null )
145
+ }
146
+ }
147
+ }
148
+
124
149
fun mergeChanges (branch : BranchReference , newVersionHash : String ): String {
125
150
var result: String? = null
126
151
store.runTransaction {
@@ -155,7 +180,7 @@ class RepositoriesManager(val client: LocalModelClient) {
155
180
? : store[legacyBranchKey(branch)]?.also { store.put(branchKey(branch), it, true ) }
156
181
}
157
182
158
- private fun putVersionHash (branch : BranchReference , hash : String ) {
183
+ private fun putVersionHash (branch : BranchReference , hash : String? ) {
159
184
store.put(branchKey(branch), hash, false )
160
185
store.put(legacyBranchKey(branch), hash, false )
161
186
}
0 commit comments