unison/unison-src/transcripts/move-namespace.output.md

367 lines
6.0 KiB
Markdown
Raw Permalink Normal View History

2022-08-23 00:48:43 +03:00
# Tests for `move.namespace`
## Moving the Root
I should be able to move the root into a sub-namespace
``` unison
foo = 1
```
``` ucm
2024-07-02 09:41:02 +03:00
scratch/main> add
⍟ 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
Done.
2024-07-02 09:41:02 +03:00
scratch/main> ls
1. root/ (1 term)
2024-07-02 09:41:02 +03:00
scratch/main> history
Note: The most recent namespace hash is immediately below this
message.
□ 1. #g97lh1m2v7 (start of history)
```
``` ucm
2024-07-02 09:41:02 +03:00
scratch/main> ls .root.at.path
1. foo (##Nat)
2024-07-02 09:41:02 +03:00
scratch/main> history .root.at.path
Note: The most recent namespace hash is immediately below this
message.
□ 1. #08a6hgi6s4 (start of history)
```
I should be able to move a sub namespace *over* the root.
``` ucm
-- Should request confirmation
2024-07-02 09:41:02 +03:00
scratch/main> move.namespace .root.at.path .
⚠️
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 .
Done.
2024-07-02 09:41:02 +03:00
scratch/main> ls
1. foo (##Nat)
2024-07-02 09:41:02 +03:00
scratch/main> history
Note: The most recent namespace hash is immediately below this
message.
□ 1. #08a6hgi6s4 (start of history)
```
``` ucm
-- should be empty
2024-07-02 09:41:02 +03:00
scratch/main> ls .root.at.path
nothing to show
2024-07-02 09:41:02 +03:00
scratch/main> history .root.at.path
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
## Happy path
Create a namespace and add some history to it
``` unison
2022-08-23 00:48:43 +03:00
a.termInA = 1
unique type a.T = T
```
``` ucm
2022-08-23 00:48:43 +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`:
type a.T
2022-08-23 00:48:43 +03:00
a.termInA : Nat
```
``` ucm
scratch/happy> add
2022-08-23 00:48:43 +03:00
⍟ I've added these definitions:
type a.T
2022-08-23 00:48:43 +03:00
a.termInA : Nat
```
``` unison
2022-08-23 00:48:43 +03:00
a.termInA = 2
unique type a.T = T1 | T2
```
``` ucm
2022-08-23 00:48:43 +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:
type a.T
2022-08-23 00:48:43 +03:00
a.termInA : Nat
```
``` ucm
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.
``` ucm
scratch/happy> move.namespace a b
2022-08-23 00:48:43 +03:00
Done.
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
scratch/happy> history b
2022-08-23 00:48:43 +03:00
Note: The most recent namespace hash is immediately below this
message.
⊙ 1. #rkvfe5p8fu
2022-08-23 00:48:43 +03:00
+ Adds / updates:
T T.T1 T.T2 termInA
- Deletes:
T.T
□ 2. #avlnmh0erc (start of history)
2022-08-23 00:48:43 +03:00
```
## Namespace history
Create some namespaces and add some history to them
``` unison
2022-08-23 00:48:43 +03:00
a.termInA = 1
b.termInB = 10
```
``` ucm
2022-08-23 00:48:43 +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
```
``` ucm
scratch/history> add
2022-08-23 00:48:43 +03:00
⍟ I've added these definitions:
a.termInA : Nat
b.termInB : Nat
```
``` unison
2022-08-23 00:48:43 +03:00
a.termInA = 2
b.termInB = 11
```
``` ucm
2022-08-23 00:48:43 +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
```
``` ucm
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
of the moved namespace.
2022-08-23 00:48:43 +03:00
``` ucm
scratch/history> delete.namespace b
2022-08-23 00:48:43 +03:00
Done.
scratch/history> move.namespace a b
2022-08-23 00:48:43 +03:00
Done.
-- Should be the history from 'a'
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
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
```
## Moving over an existing branch
2022-08-23 00:48:43 +03:00
Create some namespace and add some history to them
``` unison
2022-08-23 00:48:43 +03:00
a.termInA = 1
b.termInB = 10
```
``` ucm
2022-08-23 00:48:43 +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
```
``` ucm
scratch/existing> add
2022-08-23 00:48:43 +03:00
⍟ I've added these definitions:
a.termInA : Nat
b.termInB : Nat
```
``` unison
2022-08-23 00:48:43 +03:00
a.termInA = 2
b.termInB = 11
```
``` ucm
2022-08-23 00:48:43 +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
```
``` ucm
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
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
```