mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-17 13:27:30 +03:00
Check for empty deletes in move.namespace
This commit is contained in:
parent
71e5a60d85
commit
53af75af57
@ -340,8 +340,6 @@ loop = do
|
||||
unless (Set.null misses) $
|
||||
respond $ SearchTermsNotFound (Set.toList misses)
|
||||
traverse_ go (if isTerm then tmRefs else tpRefs)
|
||||
branchExists dest _x = respond $ BranchAlreadyExists dest
|
||||
branchExistsSplit = branchExists . Path.unsplit'
|
||||
typeExists dest = respond . TypeAlreadyExists dest
|
||||
termExists dest = respond . TermAlreadyExists dest
|
||||
inputDescription :: LoopState.InputDescription
|
||||
@ -671,16 +669,22 @@ loop = do
|
||||
BranchUtil.makeSetBranch (resolveSplit' dest) b
|
||||
]
|
||||
success
|
||||
MoveBranchI (Just src) dest ->
|
||||
maybe (branchNotFound' src) srcOk (getAtSplit' src)
|
||||
where
|
||||
srcOk b = maybe (destOk b) (branchExistsSplit dest) (getAtSplit' dest)
|
||||
destOk b = do
|
||||
stepManyAt
|
||||
[ BranchUtil.makeDeleteBranch (resolveSplit' src),
|
||||
BranchUtil.makeSetBranch (resolveSplit' dest) b
|
||||
]
|
||||
success -- could give rando stats about new defns
|
||||
MoveBranchI (Just src) dest -> unlessError $ do
|
||||
srcBranch <- case getAtSplit' src of
|
||||
Just existingSrc | not (Branch.isEmpty0 (Branch.head existingSrc)) -> do
|
||||
pure existingSrc
|
||||
_ -> throwError $ BranchNotFound (Path.unsplit' src)
|
||||
case getAtSplit' dest of
|
||||
Just existingDest
|
||||
| not (Branch.isEmpty0 (Branch.head existingDest)) -> do
|
||||
-- Branch exists and isn't empty, print an error
|
||||
throwError (BranchAlreadyExists (Path.unsplit' dest))
|
||||
_ -> pure ()
|
||||
lift $ stepManyAt
|
||||
[ BranchUtil.makeDeleteBranch (resolveSplit' src),
|
||||
BranchUtil.makeSetBranch (resolveSplit' dest) srcBranch
|
||||
]
|
||||
lift $ success -- could give rando stats about new defns
|
||||
MovePatchI src dest -> do
|
||||
psrc <- getPatchAtSplit' src
|
||||
pdest <- getPatchAtSplit' dest
|
||||
|
@ -82,6 +82,8 @@ deleted.x = 1
|
||||
stuff.thing = 2
|
||||
```
|
||||
|
||||
## fork
|
||||
|
||||
I should be allowed to fork over a deleted namespace
|
||||
|
||||
```ucm
|
||||
@ -112,3 +114,55 @@ The history from the `deleted` namespace should have been overwritten by the his
|
||||
□ #3bm1524lb7 (start of history)
|
||||
|
||||
```
|
||||
## move.namespace
|
||||
|
||||
```unison
|
||||
moveoverme.x = 1
|
||||
moveme.y = 2
|
||||
```
|
||||
|
||||
I should be able to move a namespace over-top of a deleted namespace.
|
||||
The history should be that of the moved namespace.
|
||||
|
||||
```ucm
|
||||
.> delete.namespace moveoverme
|
||||
|
||||
Removed definitions:
|
||||
|
||||
1. x : ##Nat
|
||||
|
||||
Tip: You can use `undo` or `reflog` to undo this change.
|
||||
|
||||
.> history moveme
|
||||
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
|
||||
|
||||
□ #ldl7o5e9i5 (start of history)
|
||||
|
||||
.> move.namespace moveme moveoverme
|
||||
|
||||
Done.
|
||||
|
||||
.> history moveoverme
|
||||
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
⊙ #3ahcthnkvt
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
y
|
||||
|
||||
⊙ #qjc20aua9h
|
||||
|
||||
- Deletes:
|
||||
|
||||
x
|
||||
|
||||
□ #hkrqt3tm05 (start of history)
|
||||
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user