mirror of
https://github.com/unisonweb/unison.git
synced 2024-10-26 02:55:19 +03:00
Fix up reset transcripts for projects
This commit is contained in:
parent
d0002b45c9
commit
424b43b897
@ -251,13 +251,7 @@ loop e = do
|
||||
ShowProjectReflogI mayProj -> do
|
||||
Reflogs.showProjectReflog mayProj
|
||||
ResetI newRoot mtarget -> do
|
||||
newRoot <-
|
||||
case newRoot of
|
||||
BranchAtPath p -> do
|
||||
pp <- Cli.resolvePath' p
|
||||
Cli.getBranchFromProjectPath pp
|
||||
BranchAtSCH sch -> Cli.resolveShortCausalHash sch
|
||||
BranchAtProjectPath pp -> Cli.getBranchFromProjectPath pp
|
||||
newRoot <- resolveBranchId2 newRoot
|
||||
target <-
|
||||
case mtarget of
|
||||
Nothing -> Cli.getCurrentProjectPath
|
||||
@ -902,11 +896,8 @@ inputDescription input =
|
||||
Branch.RegularMerge -> "merge"
|
||||
Branch.SquashMerge -> "merge.squash"
|
||||
pure (command <> " " <> src <> " " <> dest)
|
||||
ResetI hash tgt -> do
|
||||
hashTxt <- case hash of
|
||||
BranchAtSCH hash -> hp' $ Left hash
|
||||
BranchAtPath pr -> pure $ into @Text pr
|
||||
BranchAtProjectPath pp -> pure $ into @Text pp
|
||||
ResetI newRoot tgt -> do
|
||||
hashTxt <- bid2 newRoot
|
||||
tgt <- case tgt of
|
||||
Nothing -> pure ""
|
||||
Just tgt -> do
|
||||
@ -1074,8 +1065,6 @@ inputDescription input =
|
||||
UpgradeCommitI {} -> wat
|
||||
VersionI -> wat
|
||||
where
|
||||
hp' :: Either SCH.ShortCausalHash Path' -> Cli Text
|
||||
hp' = either (pure . into @Text) p'
|
||||
p :: Path -> Cli Text
|
||||
p = fmap (into @Text) . Cli.resolvePath
|
||||
p' :: Path' -> Cli Text
|
||||
@ -1096,6 +1085,10 @@ inputDescription input =
|
||||
hqs (p, hq) = hqs' (Path' . Right . Path.Relative $ p, hq)
|
||||
ps' = p' . Path.unsplit'
|
||||
ps = p . Path.unsplit
|
||||
bid2 :: BranchId2 -> Cli Text
|
||||
bid2 = \case
|
||||
Left sch -> pure $ into @Text sch
|
||||
Right p -> brp p
|
||||
|
||||
handleFindI ::
|
||||
Bool ->
|
||||
|
@ -126,9 +126,9 @@ data Input
|
||||
| PullI !PullSourceTarget !PullMode
|
||||
| PushRemoteBranchI PushRemoteBranchInput
|
||||
| ResetRootI BranchId
|
||||
| ResetI BranchId (Maybe UnresolvedProjectBranch)
|
||||
| -- todo: Q: Does it make sense to publish to not-the-root of a Github repo?
|
||||
-- Does it make sense to fork from not-the-root of a Github repo?
|
||||
| ResetI (BranchId2 {- namespace to reset it to -}) (Maybe UnresolvedProjectBranch {- ProjectBranch to reset -})
|
||||
-- todo: Q: Does it make sense to publish to not-the-root of a Github repo?
|
||||
| -- Does it make sense to fork from not-the-root of a Github repo?
|
||||
-- used in Welcome module to give directions to user
|
||||
CreateMessage (P.Pretty P.ColorText)
|
||||
| -- Change directory.
|
||||
|
@ -1663,8 +1663,8 @@ reset =
|
||||
]
|
||||
)
|
||||
\case
|
||||
[arg0] -> Input.ResetI <$> handleBranchIdArg arg0 <*> pure Nothing
|
||||
[arg0, arg1] -> Input.ResetI <$> handleBranchIdArg arg0 <*> fmap pure (handleMaybeProjectBranchArg arg1)
|
||||
[resetTo] -> Input.ResetI <$> handleBranchId2Arg resetTo <*> pure Nothing
|
||||
[resetTo, branchToReset] -> Input.ResetI <$> handleBranchId2Arg resetTo <*> fmap pure (handleMaybeProjectBranchArg branchToReset)
|
||||
args -> wrongArgsLength "one or two arguments" args
|
||||
where
|
||||
config =
|
||||
|
@ -2,28 +2,36 @@
|
||||
scratch/main> builtins.merge
|
||||
```
|
||||
|
||||
# reset loose code
|
||||
```unison
|
||||
a = 5
|
||||
def = "first value"
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
scratch/main> update
|
||||
```
|
||||
|
||||
```unison:hide
|
||||
def = "second value"
|
||||
```
|
||||
|
||||
Can reset to a value from history by number.
|
||||
|
||||
```ucm
|
||||
scratch/main> add
|
||||
scratch/main> update
|
||||
scratch/main> history
|
||||
scratch/main> reset 2
|
||||
scratch/main> view def
|
||||
scratch/main> history
|
||||
```
|
||||
|
||||
```unison
|
||||
foo.a = 5
|
||||
```
|
||||
Can reset to a value from reflog by number.
|
||||
|
||||
```ucm
|
||||
scratch/main> add
|
||||
scratch/main> ls foo
|
||||
scratch/main> reflog
|
||||
-- Reset the current branch to the first history element
|
||||
scratch/main> reset 2
|
||||
scratch/main> view def
|
||||
scratch/main> history
|
||||
scratch/main> reset 1 foo
|
||||
scratch/main> ls foo.foo
|
||||
```
|
||||
|
||||
# reset branch
|
||||
@ -32,47 +40,24 @@ scratch/main> ls foo.foo
|
||||
foo/main> history
|
||||
```
|
||||
|
||||
```unison
|
||||
```unison:hide
|
||||
a = 5
|
||||
```
|
||||
|
||||
```ucm
|
||||
foo/main> add
|
||||
foo/main> branch topic
|
||||
foo/main> history
|
||||
foo/main> update
|
||||
foo/empty> reset /main:.
|
||||
foo/empty> view a
|
||||
foo/empty> history
|
||||
```
|
||||
|
||||
```unison
|
||||
a = 3
|
||||
## second argument is always interpreted as a branch
|
||||
```unison:hide
|
||||
main.a = 3
|
||||
```
|
||||
|
||||
```ucm
|
||||
foo/main> update
|
||||
foo/main> reset /topic
|
||||
foo/main> history
|
||||
```
|
||||
|
||||
# ambiguous reset
|
||||
|
||||
## ambiguous target
|
||||
```unison
|
||||
main.a = 3
|
||||
```
|
||||
|
||||
```ucm:error
|
||||
foo/main> add
|
||||
foo/main> history
|
||||
foo/main> reset 2 main
|
||||
```
|
||||
|
||||
## ambiguous hash
|
||||
|
||||
```unison
|
||||
main.a = 3
|
||||
```
|
||||
|
||||
```ucm:error
|
||||
foo/main> switch /topic
|
||||
foo/topic> add
|
||||
foo/topic> reset main
|
||||
```
|
||||
|
@ -1,6 +1,5 @@
|
||||
# reset loose code
|
||||
```unison
|
||||
a = 5
|
||||
def = "first value"
|
||||
```
|
||||
|
||||
```ucm
|
||||
@ -13,30 +12,20 @@ a = 5
|
||||
|
||||
⍟ These new definitions are ok to `add`:
|
||||
|
||||
a : Nat
|
||||
def : Text
|
||||
|
||||
```
|
||||
```unison
|
||||
def = "second value"
|
||||
```
|
||||
|
||||
Can reset to a value from history by number.
|
||||
|
||||
```ucm
|
||||
scratch/main> add
|
||||
scratch/main> update
|
||||
|
||||
⍟ I've added these definitions:
|
||||
|
||||
a : Nat
|
||||
|
||||
scratch/main> history
|
||||
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
⊙ 1. #d079vet1oj
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
a
|
||||
|
||||
□ 2. #4bigcpnl7t (start of history)
|
||||
|
||||
scratch/main> reset 2
|
||||
Okay, I'm searching the branch for code that needs to be
|
||||
updated...
|
||||
|
||||
Done.
|
||||
|
||||
@ -45,67 +34,164 @@ scratch/main> history
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
⊙ 1. #5vq851j3hg
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
□ 1. #4bigcpnl7t (start of history)
|
||||
def
|
||||
|
||||
```
|
||||
```unison
|
||||
foo.a = 5
|
||||
```
|
||||
⊙ 2. #ujvq6e87kp
|
||||
|
||||
```ucm
|
||||
+ Adds / updates:
|
||||
|
||||
Loading changes detected in scratch.u.
|
||||
def
|
||||
|
||||
I found and typechecked these definitions in scratch.u. If you
|
||||
do an `add` or `update`, here's how your codebase would
|
||||
change:
|
||||
□ 3. #4bigcpnl7t (start of history)
|
||||
|
||||
⍟ These new definitions are ok to `add`:
|
||||
scratch/main> reset 2
|
||||
|
||||
foo.a : Nat
|
||||
Done.
|
||||
|
||||
```
|
||||
```ucm
|
||||
scratch/main> add
|
||||
scratch/main> view def
|
||||
|
||||
⍟ I've added these definitions:
|
||||
|
||||
foo.a : Nat
|
||||
|
||||
scratch/main> ls foo
|
||||
|
||||
1. a (Nat)
|
||||
def : Text
|
||||
def = "first value"
|
||||
|
||||
scratch/main> history
|
||||
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
⊙ 1. #tfg7r9359n
|
||||
⊙ 1. #ujvq6e87kp
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
foo.a
|
||||
def
|
||||
|
||||
□ 2. #4bigcpnl7t (start of history)
|
||||
|
||||
scratch/main> reset 1 foo
|
||||
```
|
||||
Can reset to a value from reflog by number.
|
||||
|
||||
scratch/foo does not exist.
|
||||
```ucm
|
||||
scratch/main> reflog
|
||||
|
||||
Below is a record of recent changes, you can use
|
||||
`reset #abcdef` to reset the current branch to a previous
|
||||
state.
|
||||
|
||||
Tip: Use `diff.namespace 1 7` to compare between points in
|
||||
history.
|
||||
|
||||
Branch When Hash Description
|
||||
1. scratch/main now #ujvq6e87kp reset ujvq6e87kp4288eq3al9v5luctic0ocd7ug1fu0go5bicrr2vfnrb0...
|
||||
2. scratch/main now #5vq851j3hg update
|
||||
3. scratch/main now #ujvq6e87kp update
|
||||
4. scratch/main now #4bigcpnl7t builtins.merge
|
||||
5. scratch/main now #sg60bvjo91 Project Created
|
||||
|
||||
-- Reset the current branch to the first history element
|
||||
scratch/main> reset 2
|
||||
|
||||
Done.
|
||||
|
||||
scratch/main> view def
|
||||
|
||||
def : Text
|
||||
def = "second value"
|
||||
|
||||
scratch/main> history
|
||||
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
⊙ 1. #5vq851j3hg
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
def
|
||||
|
||||
⊙ 2. #ujvq6e87kp
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
def
|
||||
|
||||
□ 3. #4bigcpnl7t (start of history)
|
||||
|
||||
```
|
||||
# reset branch
|
||||
|
||||
```ucm
|
||||
foo/main> history
|
||||
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
|
||||
|
||||
□ 1. #sg60bvjo91 (start of history)
|
||||
|
||||
```
|
||||
```unison
|
||||
a = 5
|
||||
```
|
||||
|
||||
```ucm
|
||||
scratch/main> addscratch/main> ls fooscratch/main> historyscratch/main> reset 1 fooscratch/main> ls foo.foo
|
||||
foo/main> update
|
||||
|
||||
Okay, I'm searching the branch for code that needs to be
|
||||
updated...
|
||||
|
||||
Done.
|
||||
|
||||
foo/empty> reset /main:.
|
||||
|
||||
Done.
|
||||
|
||||
foo/empty> view a
|
||||
|
||||
a : ##Nat
|
||||
a = 5
|
||||
|
||||
foo/empty> history
|
||||
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
|
||||
|
||||
□ 1. #5l94rduvel (start of history)
|
||||
|
||||
```
|
||||
## second argument is always interpreted as a branch
|
||||
```unison
|
||||
main.a = 3
|
||||
```
|
||||
|
||||
```ucm
|
||||
foo/main> update
|
||||
|
||||
🛑
|
||||
Okay, I'm searching the branch for code that needs to be
|
||||
updated...
|
||||
|
||||
The transcript failed due to an error in the stanza above. The error is:
|
||||
Done.
|
||||
|
||||
foo/main> history
|
||||
|
||||
scratch/foo does not exist.
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
⊙ 1. #0i64kpfccl
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
main.a
|
||||
|
||||
□ 2. #5l94rduvel (start of history)
|
||||
|
||||
foo/main> reset 2 main
|
||||
|
||||
Done.
|
||||
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user