2022-08-23 00:48:43 +03:00
|
|
|
# Tests for `move.namespace`
|
|
|
|
|
2024-06-26 21:29:08 +03:00
|
|
|
## Moving the Root
|
|
|
|
|
|
|
|
I should be able to move the root into a sub-namespace
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2024-06-26 21:29:08 +03:00
|
|
|
foo = 1
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> add
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
|
|
|
|
|
|
|
foo : ##Nat
|
|
|
|
|
2024-07-10 20:37:08 +03:00
|
|
|
-- Should request confirmation
|
|
|
|
scratch/main> move.namespace . .root.at.path
|
|
|
|
|
|
|
|
⚠️
|
|
|
|
|
|
|
|
Moves which affect the root branch cannot be undone, are you sure?
|
|
|
|
Re-run the same command to proceed.
|
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> move.namespace . .root.at.path
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
Done.
|
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> ls
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
1. root/ (1 term)
|
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> history
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
Note: The most recent namespace hash is immediately below this
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
□ 1. #g97lh1m2v7 (start of history)
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> ls .root.at.path
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
1. foo (##Nat)
|
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> history .root.at.path
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
Note: The most recent namespace hash is immediately below this
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
□ 1. #08a6hgi6s4 (start of history)
|
|
|
|
|
|
|
|
```
|
2024-07-10 17:46:18 +03:00
|
|
|
I should be able to move a sub namespace *over* the root.
|
2024-06-26 21:29:08 +03:00
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
-- Should request confirmation
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> move.namespace .root.at.path .
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
⚠️
|
|
|
|
|
2024-07-10 20:37:08 +03:00
|
|
|
Moves which affect the root branch cannot be undone, are you sure?
|
|
|
|
Re-run the same command to proceed.
|
|
|
|
|
|
|
|
scratch/main> move.namespace .root.at.path .
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
Done.
|
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> ls
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
1. foo (##Nat)
|
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> history
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
Note: The most recent namespace hash is immediately below this
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
□ 1. #08a6hgi6s4 (start of history)
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
-- should be empty
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> ls .root.at.path
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
nothing to show
|
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
scratch/main> history .root.at.path
|
2024-06-26 21:29:08 +03:00
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
Note: The most recent namespace hash is immediately below this
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
□ 1. #sg60bvjo91 (start of history)
|
2024-06-26 21:29:08 +03:00
|
|
|
|
|
|
|
```
|
2022-08-23 00:48:43 +03:00
|
|
|
## Happy path
|
|
|
|
|
|
|
|
Create a namespace and add some history to it
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA = 1
|
|
|
|
unique type a.T = T
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2022-08-23 00:48:43 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
2024-01-04 11:42:12 +03:00
|
|
|
type a.T
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/happy> add
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
|
|
|
|
2024-01-04 11:42:12 +03:00
|
|
|
type a.T
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA = 2
|
|
|
|
unique type a.T = T1 | T2
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2022-08-23 00:48:43 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These names already exist. You can `update` them to your
|
|
|
|
new definition:
|
|
|
|
|
2024-01-04 11:42:12 +03:00
|
|
|
type a.T
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/happy> update
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-11-14 06:36:03 +03:00
|
|
|
Okay, I'm searching the branch for code that needs to be
|
|
|
|
updated...
|
|
|
|
|
2023-11-08 19:54:50 +03:00
|
|
|
Done.
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Should be able to move the namespace, including its types, terms, and sub-namespaces.
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/happy> move.namespace a b
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
Done.
|
|
|
|
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/happy> ls b
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
1. T (type)
|
2022-09-01 20:34:36 +03:00
|
|
|
2. T/ (2 terms)
|
2024-01-12 20:39:18 +03:00
|
|
|
3. termInA (Nat)
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/happy> history b
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
Note: The most recent namespace hash is immediately below this
|
|
|
|
message.
|
|
|
|
|
2024-06-26 21:29:08 +03:00
|
|
|
⊙ 1. #rkvfe5p8fu
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
+ Adds / updates:
|
|
|
|
|
|
|
|
T T.T1 T.T2 termInA
|
|
|
|
|
|
|
|
- Deletes:
|
|
|
|
|
|
|
|
T.T
|
|
|
|
|
2024-06-26 21:29:08 +03:00
|
|
|
□ 2. #avlnmh0erc (start of history)
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
## Namespace history
|
|
|
|
|
|
|
|
Create some namespaces and add some history to them
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA = 1
|
|
|
|
b.termInB = 10
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2022-08-23 00:48:43 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
|
|
|
a.termInA : Nat
|
|
|
|
b.termInB : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/history> add
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
|
|
|
|
|
|
|
a.termInA : Nat
|
|
|
|
b.termInB : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA = 2
|
|
|
|
b.termInB = 11
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2022-08-23 00:48:43 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These names already exist. You can `update` them to your
|
|
|
|
new definition:
|
|
|
|
|
|
|
|
a.termInA : Nat
|
|
|
|
b.termInB : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/history> update
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-11-14 06:36:03 +03:00
|
|
|
Okay, I'm searching the branch for code that needs to be
|
|
|
|
updated...
|
|
|
|
|
2023-11-08 19:54:50 +03:00
|
|
|
Done.
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
```
|
2023-01-30 20:08:34 +03:00
|
|
|
Deleting a namespace should not leave behind any history,
|
|
|
|
if we move another to that location we expect the history to simply be the history
|
2024-06-26 21:29:08 +03:00
|
|
|
of the moved namespace.
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/history> delete.namespace b
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
Done.
|
|
|
|
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/history> move.namespace a b
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
Done.
|
|
|
|
|
|
|
|
-- Should be the history from 'a'
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/history> history b
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
Note: The most recent namespace hash is immediately below this
|
|
|
|
message.
|
|
|
|
|
|
|
|
⊙ 1. #j0cjjqepb3
|
|
|
|
|
|
|
|
+ Adds / updates:
|
|
|
|
|
|
|
|
termInA
|
|
|
|
|
|
|
|
□ 2. #m8smmmgjso (start of history)
|
|
|
|
|
|
|
|
-- Should be empty
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/history> history a
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2024-07-02 09:41:02 +03:00
|
|
|
Note: The most recent namespace hash is immediately below this
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
□ 1. #sg60bvjo91 (start of history)
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
```
|
2024-06-26 21:29:08 +03:00
|
|
|
## Moving over an existing branch
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
Create some namespace and add some history to them
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA = 1
|
|
|
|
b.termInB = 10
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2022-08-23 00:48:43 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
|
|
|
a.termInA : Nat
|
|
|
|
b.termInB : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/existing> add
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
|
|
|
|
|
|
|
a.termInA : Nat
|
|
|
|
b.termInB : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2022-08-23 00:48:43 +03:00
|
|
|
a.termInA = 2
|
|
|
|
b.termInB = 11
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2022-08-23 00:48:43 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These names already exist. You can `update` them to your
|
|
|
|
new definition:
|
|
|
|
|
|
|
|
a.termInA : Nat
|
|
|
|
b.termInB : Nat
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/existing> update
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-11-14 06:36:03 +03:00
|
|
|
Okay, I'm searching the branch for code that needs to be
|
|
|
|
updated...
|
|
|
|
|
2023-11-08 19:54:50 +03:00
|
|
|
Done.
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2024-06-26 21:29:08 +03:00
|
|
|
scratch/existing> move.namespace a b
|
2022-08-23 00:48:43 +03:00
|
|
|
|
|
|
|
⚠️
|
|
|
|
|
|
|
|
A branch existed at the destination: b so I over-wrote it.
|
|
|
|
|
2024-07-23 00:36:51 +03:00
|
|
|
Tip: You can use `undo` or use a hash from `reflog` to undo
|
|
|
|
this change.
|
2022-08-23 00:48:43 +03:00
|
|
|
|
2023-12-01 01:03:42 +03:00
|
|
|
Done.
|
|
|
|
|
2022-08-23 00:48:43 +03:00
|
|
|
```
|