mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
Merge pull request #4886 from unisonweb/builtins.merge-in
add an optional destination path to `builtins.merge{,io}`
This commit is contained in:
commit
ad09964825
@ -967,7 +967,7 @@ loop e = do
|
||||
-- stepAt updateBuiltins
|
||||
-- checkTodo
|
||||
|
||||
MergeBuiltinsI -> do
|
||||
MergeBuiltinsI opath -> do
|
||||
Cli.Env {codebase} <- ask
|
||||
description <- inputDescription input
|
||||
-- these were added once, but maybe they've changed and need to be
|
||||
@ -983,10 +983,13 @@ loop e = do
|
||||
-- due to builtin terms; so we don't just reuse `uf` above.
|
||||
let srcb = BranchUtil.fromNames Builtin.names
|
||||
currentPath <- Cli.getCurrentPath
|
||||
_ <- Cli.updateAtM description (currentPath `snoc` "builtin") \destb ->
|
||||
let destPath = case opath of
|
||||
Just path -> Path.resolve currentPath (Path.Relative path)
|
||||
Nothing -> currentPath `snoc` "builtin"
|
||||
_ <- Cli.updateAtM description destPath \destb ->
|
||||
liftIO (Branch.merge'' (Codebase.lca codebase) Branch.RegularMerge srcb destb)
|
||||
Cli.respond Success
|
||||
MergeIOBuiltinsI -> do
|
||||
MergeIOBuiltinsI opath -> do
|
||||
Cli.Env {codebase} <- ask
|
||||
description <- inputDescription input
|
||||
-- these were added once, but maybe they've changed and need to be
|
||||
@ -1007,7 +1010,10 @@ loop e = do
|
||||
let names0 = Builtin.names <> UF.typecheckedToNames IOSource.typecheckedFile'
|
||||
let srcb = BranchUtil.fromNames names0
|
||||
currentPath <- Cli.getCurrentPath
|
||||
_ <- Cli.updateAtM description (currentPath `snoc` "builtin") \destb ->
|
||||
let destPath = case opath of
|
||||
Just path -> Path.resolve currentPath (Path.Relative path)
|
||||
Nothing -> currentPath `snoc` "builtin"
|
||||
_ <- Cli.updateAtM description destPath \destb ->
|
||||
liftIO (Branch.merge'' (Codebase.lca codebase) Branch.RegularMerge srcb destb)
|
||||
Cli.respond Success
|
||||
ListEditsI maybePath -> do
|
||||
@ -1305,8 +1311,10 @@ inputDescription input =
|
||||
IOTestI hq -> pure ("io.test " <> HQ.toText hq)
|
||||
IOTestAllI -> pure "io.test.all"
|
||||
UpdateBuiltinsI -> pure "builtins.update"
|
||||
MergeBuiltinsI -> pure "builtins.merge"
|
||||
MergeIOBuiltinsI -> pure "builtins.mergeio"
|
||||
MergeBuiltinsI Nothing -> pure "builtins.merge"
|
||||
MergeBuiltinsI (Just path) -> ("builtins.merge " <>) <$> p path
|
||||
MergeIOBuiltinsI Nothing -> pure "builtins.mergeio"
|
||||
MergeIOBuiltinsI (Just path) -> ("builtins.mergeio " <>) <$> p path
|
||||
MakeStandaloneI out nm -> pure ("compile " <> Text.pack out <> " " <> HQ.toText nm)
|
||||
ExecuteSchemeI nm args ->
|
||||
pure $ "run.native " <> Text.unwords (nm : fmap Text.pack args)
|
||||
@ -1395,6 +1403,8 @@ inputDescription input =
|
||||
where
|
||||
hp' :: Either SCH.ShortCausalHash Path' -> Cli Text
|
||||
hp' = either (pure . Text.pack . show) p'
|
||||
p :: Path -> Cli Text
|
||||
p = fmap tShow . Cli.resolvePath
|
||||
p' :: Path' -> Cli Text
|
||||
p' = fmap tShow . Cli.resolvePath'
|
||||
brp :: BranchRelativePath -> Cli Text
|
||||
|
@ -202,8 +202,8 @@ data Input
|
||||
| ShowDefinitionByPrefixI OutputLocation [HQ.HashQualified Name]
|
||||
| ShowReflogI
|
||||
| UpdateBuiltinsI
|
||||
| MergeBuiltinsI
|
||||
| MergeIOBuiltinsI
|
||||
| MergeBuiltinsI (Maybe Path)
|
||||
| MergeIOBuiltinsI (Maybe Path)
|
||||
| ListDependenciesI (HQ.HashQualified Name)
|
||||
| ListDependentsI (HQ.HashQualified Name)
|
||||
| -- | List all external dependencies of a given namespace, or the current namespace if
|
||||
|
@ -105,9 +105,14 @@ mergeBuiltins =
|
||||
"builtins.merge"
|
||||
[]
|
||||
I.Hidden
|
||||
[]
|
||||
"Adds the builtins to `builtins.` in the current namespace (excluding `io` and misc)."
|
||||
(const . pure $ Input.MergeBuiltinsI)
|
||||
[("namespace", Optional, namespaceArg)]
|
||||
"Adds the builtins (excluding `io` and misc) to the specified namespace. Defaults to `builtin.`"
|
||||
\case
|
||||
[] -> pure . Input.MergeBuiltinsI $ Nothing
|
||||
[p] -> first P.text do
|
||||
p <- Path.parsePath p
|
||||
pure . Input.MergeBuiltinsI $ Just p
|
||||
_ -> Left (I.help mergeBuiltins)
|
||||
|
||||
mergeIOBuiltins :: InputPattern
|
||||
mergeIOBuiltins =
|
||||
@ -115,9 +120,14 @@ mergeIOBuiltins =
|
||||
"builtins.mergeio"
|
||||
[]
|
||||
I.Hidden
|
||||
[]
|
||||
"Adds all the builtins to `builtins.` in the current namespace, including `io` and misc."
|
||||
(const . pure $ Input.MergeIOBuiltinsI)
|
||||
[("namespace", Optional, namespaceArg)]
|
||||
"Adds all the builtins, including `io` and misc., to the specified namespace. Defaults to `builtin.`"
|
||||
\case
|
||||
[] -> pure . Input.MergeIOBuiltinsI $ Nothing
|
||||
[p] -> first P.text do
|
||||
p <- Path.parsePath p
|
||||
pure . Input.MergeIOBuiltinsI $ Just p
|
||||
_ -> Left (I.help mergeBuiltins)
|
||||
|
||||
updateBuiltins :: InputPattern
|
||||
updateBuiltins =
|
||||
|
@ -3,8 +3,7 @@ If `foo#old` exists in old, and `foo#new` exists in new, you might think `upgrad
|
||||
|
||||
```ucm:hide
|
||||
.> project.create-empty foo
|
||||
foo/main> builtins.merge
|
||||
foo/main> move.namespace builtin lib.builtin
|
||||
foo/main> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,5 +1,5 @@
|
||||
```ucm:hide
|
||||
.lib> builtins.mergeio
|
||||
.> builtins.mergeio lib.builtin
|
||||
```
|
||||
|
||||
```unison:hide
|
||||
|
@ -1,7 +1,6 @@
|
||||
```ucm:hide
|
||||
.> project.create-empty myproject
|
||||
myproject/main> builtins.merge
|
||||
myproject/main> move.namespace builtin lib.builtin
|
||||
myproject/main> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -25,4 +24,3 @@ file to stare at.
|
||||
```ucm:error
|
||||
.> update
|
||||
```
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,6 +1,5 @@
|
||||
```ucm:hide
|
||||
.> builtins.merge
|
||||
.> move.namespace builtin lib.builtin
|
||||
.> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,7 +1,6 @@
|
||||
```ucm:hide
|
||||
.> project.create-empty proj
|
||||
proj/main> builtins.merge
|
||||
proj/main> move.namespace builtin lib.builtin
|
||||
proj/main> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -1,7 +1,6 @@
|
||||
```ucm:hide
|
||||
.> project.create-empty proj
|
||||
proj/main> builtins.merge
|
||||
proj/main> move.namespace builtin lib.builtin
|
||||
proj/main> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -17,4 +16,3 @@ proj/main> add
|
||||
```ucm:error
|
||||
proj/main> upgrade old new
|
||||
```
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
```ucm:hide
|
||||
.> project.create-empty myproject
|
||||
myproject/main> builtins.merge
|
||||
myproject/main> move.namespace builtin lib.builtin
|
||||
myproject/main> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -21,4 +20,3 @@ myproject/main> add
|
||||
```ucm:error
|
||||
myproject/main> upgrade old new
|
||||
```
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
```ucm:hide
|
||||
.> project.create-empty myproject
|
||||
myproject/main> builtins.merge
|
||||
myproject/main> move.namespace builtin lib.builtin
|
||||
myproject/main> builtins.merge lib.builtin
|
||||
```
|
||||
|
||||
```unison
|
||||
|
Loading…
Reference in New Issue
Block a user