Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput/Delete.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ handleDelete False {- force? -} which (List.nubOrd -> targetNames) = do

projectAndBranch <- Cli.getCurrentProjectAndBranch

when (projectAndBranch.branch.isUpdate || projectAndBranch.branch.isUpgrade) do
Cli.returnEarly
if projectAndBranch.branch.isUpdate
then Output.CantDoThatDuring "an update" "update"
else Output.CantDoThatDuring "an upgrade" "upgrade"
when projectAndBranch.branch.isUpdate (Cli.returnEarly (Output.CantDoThatDuring "an update" "update"))
when projectAndBranch.branch.isUpgrade (Cli.returnEarly (Output.CantDoThatDuring "an upgrade" "upgrade"))
when projectAndBranch.branch.isUpgrade (Cli.returnEarly (Output.CantDoThatDuring "a merge" "merge"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small oversight fixed, can't delete during a merge either


currentNamespace <- Cli.getCurrentProjectRoot
let currentNamespace0 = Branch.head currentNamespace
Expand Down Expand Up @@ -198,7 +196,7 @@ handleDelete False {- force? -} which (List.nubOrd -> targetNames) = do

-- A failed delete makes an "update" branch, since it behaves like an update branch in every way. We even name the
-- branch update-* so it doesn't feel like a weird new thing.
(_updateBranchId, updateBranchName) <-
(_updateBranchId, _updateBranchName) <-
HandleInput.Branch.createBranch
("update " <> into @Text (ProjectAndBranch projectAndBranch.project.name projectAndBranch.branch.name))
( HandleInput.Branch.CreateFrom'Update
Expand Down Expand Up @@ -244,7 +242,7 @@ handleDelete False {- force? -} which (List.nubOrd -> targetNames) = do

liftIO $ env.writeSource (Text.pack scratchFilePath) (Pretty.toPlain 80 prettyUnisonFile) True

Cli.returnEarly (Output.DeleteFailure scratchFilePath projectAndBranch.branch.name updateBranchName)
Cli.returnEarly (Output.DeleteFailure scratchFilePath projectAndBranch.branch.name)

-- Identify the delete actions to apply to the current branch. This is just the delete target, plus constructors.
let deleteActions :: [(Path.Absolute, Branch0 m -> Branch0 m)]
Expand Down
4 changes: 2 additions & 2 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ handleUpdate2 = do
uniqueTypeGuidsByName <-
Cli.runTransaction (makeUniqueTypeGuids (BiMultimap.range unconflictedView.defns.types))

(_updateBranchId, updateBranchName) <-
(_updateBranchId, _updateBranchName) <-
HandleInput.Branch.createBranch
("update " <> into @Text (ProjectAndBranch pp.project.name pp.branch.name))
( HandleInput.Branch.CreateFrom'Update
Expand All @@ -209,7 +209,7 @@ handleUpdate2 = do
scratchFilePath <- fst <$> Cli.expectLatestFile
#latestFile ?= (scratchFilePath, True)
liftIO $ env.writeSource (Text.pack scratchFilePath) (Pretty.toPlain 80 prettyUnisonFile) True
done (Output.UpdateTypecheckingFailure2 scratchFilePath pp.branch.name updateBranchName)
done (Output.UpdateTypecheckingFailure2 scratchFilePath pp.branch.name)
else do
scratchFilePath <- fst <$> Cli.expectLatestFile
#latestFile ?= (scratchFilePath, True)
Expand Down
4 changes: 2 additions & 2 deletions unison-cli/src/Unison/Codebase/Editor/Output.hs
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ data Output
| FailedToFetchLatestReleaseOfBase
| HappyCoding
| ProjectHasNoReleases ProjectName
| DeleteFailure !FilePath !ProjectBranchName !ProjectBranchName
| DeleteFailure !FilePath !ProjectBranchName
| UpdateTypecheckingFailure
| UpdateTypecheckingFailure2 !FilePath !ProjectBranchName !ProjectBranchName
| UpdateTypecheckingFailure2 !FilePath !ProjectBranchName
| UpgradeFailure !ProjectBranchName !FilePath !NameSegment !NameSegment
| UpgradeSuccess !NameSegment !NameSegment !(Maybe NameSegment)
| MergeFailure !FilePath !MergeSourceAndTarget
Expand Down
96 changes: 41 additions & 55 deletions unison-cli/src/Unison/CommandLine/OutputMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2002,25 +2002,16 @@ notifyUser dir issueFn = \case
<> P.wrap "🎉 🥳 Happy coding!"
ProjectHasNoReleases projectName ->
pure . P.wrap $ prettyProjectName projectName <> "has no releases."
DeleteFailure scratchFile0 baseBranch updateBranch -> do
DeleteFailure scratchFile0 baseBranch -> do
scratchFile <- renderFileName scratchFile0
pure $
P.wrap
( "Some definitions depend on the ones you're trying to delete. I've added them to"
<> P.group (scratchFile <> ",")
<> "where you can fix them or comment them out. Once the file is compiling, run"
<> P.group (makeExample' IP.update <> ".")
)
P.wrap "I couldn't complete the delete, because some definitions are still in use."
<> P.newline
<> P.newline
<> P.wrap
( "I've also switched you to a new branch"
<> prettyProjectBranchName updateBranch
<> "for this work. On"
<> P.group (makeExample' IP.update <> ",")
<> "it will be merged back into"
<> P.group (prettyProjectBranchName baseBranch <> ".")
)
<> iveCreatedATemporaryBranch scratchFile
<> P.newline
<> P.newline
<> onceYoureHappy baseBranch
UpdateTypecheckingFailure ->
pure . P.wrap $
"Typechecking failed. I've updated your scratch file with the definitions that need fixing."
Expand All @@ -2029,52 +2020,31 @@ notifyUser dir issueFn = \case
<> "Once the file is compiling, try"
<> makeExample' IP.update
<> "again."
UpdateTypecheckingFailure2 scratchFile0 baseBranch updateBranch -> do
UpdateTypecheckingFailure2 scratchFile0 baseBranch -> do
scratchFile <- renderFileName scratchFile0
pure $
P.wrap "I couldn't complete the update, because some existing definitions would no longer typecheck."
<> P.newline
<> P.newline
<> iveCreatedATemporaryBranch scratchFile
<> P.newline
<> P.newline
<> onceYoureHappy baseBranch
UpgradeFailure baseBranch scratchFile0 old new -> do
scratchFile <- renderFileName scratchFile0
pure $
P.wrap
( "Some definitions don't typecheck with your changes. I've updated the file"
<> scratchFile
<> "with the definitions that need fixing. Once the file is compiling, try"
<> makeExample' IP.update
<> "again."
( "I couldn't automatically upgrade"
<> P.text (NameSegment.toEscapedText old)
<> "to"
<> P.group (P.text (NameSegment.toEscapedText new) <> ".")
)
<> P.newline
<> P.newline
<> P.wrap
( "I've also switched you to a new branch"
<> prettyProjectBranchName updateBranch
<> "for this work. On"
<> P.group (makeExample' IP.update <> ",")
<> "it will be merged back into"
<> P.group (prettyProjectBranchName baseBranch <> ".")
)
UpgradeFailure main path old new ->
pure $
P.lines
[ P.wrap $
"I couldn't automatically upgrade"
<> P.text (NameSegment.toEscapedText old)
<> "to"
<> P.group (P.text (NameSegment.toEscapedText new) <> ".")
<> "However, I've added the definitions that need attention to the top of"
<> P.group (prettyFilePath path <> "."),
"",
P.wrap "When you're done, you can run",
"",
P.indentN 2 (IP.makeExampleNoBackticks IP.update []),
"",
P.wrap $
"to merge your changes back into"
<> prettyProjectBranchName main
<> "and delete the temporary branch. Or, if you decide to cancel the upgrade instead, you can run",
"",
P.indentN 2 (IP.makeExampleNoBackticks IP.cancelInputPattern []),
"",
P.wrap $
"to delete the temporary branch and switch back to"
<> P.group (prettyProjectBranchName main <> ".")
]
<> iveCreatedATemporaryBranch scratchFile
<> P.newline
<> P.newline
<> onceYoureHappy baseBranch
UpgradeSuccess old new maybeFinal ->
let prettyLib = P.blue . P.text . NameSegment.toEscapedText
prettyOld = prettyLib old
Expand Down Expand Up @@ -2373,6 +2343,22 @@ notifyUser dir issueFn = \case
<> "Please complete the"
<> (P.group (P.text verb) <> ",")
<> "then try again."
where
iveCreatedATemporaryBranch scratchFile =
P.wrap $
"I've created a temporary branch and added the affected definitions to"
<> P.group (scratchFile <> ",")
<> "where you can fix them up or remove any that are obsolete."

onceYoureHappy baseBranch =
P.wrap $
"Once you're happy with the results, use"
<> makeExample' IP.update
<> "to merge them back into"
<> P.group (prettyProjectBranchName baseBranch <> ",")
<> "or"
<> makeExample' IP.cancelInputPattern
<> "if you change your mind."

prettyShareError :: ShareError -> Pretty
prettyShareError =
Expand Down
32 changes: 14 additions & 18 deletions unison-src/transcripts/idempotent/cancel.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ scratch/main> update

That's done. Now I'm making sure everything typechecks...

Some definitions don't typecheck with your changes. I've
updated the file scratch.u with the definitions that need
fixing. Once the file is compiling, try `update` again.
I couldn't complete the update, because some existing
definitions would no longer typecheck.

I've also switched you to a new branch update-main for this
work. On `update`, it will be merged back into main.
I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down Expand Up @@ -119,21 +122,14 @@ scratch/main> update
``` ucm :error
scratch/main> upgrade old new

I couldn't automatically upgrade old to new. However, I've
added the definitions that need attention to the top of
scratch.u.

When you're done, you can run
I couldn't automatically upgrade old to new.

update

to merge your changes back into main and delete the temporary
branch. Or, if you decide to cancel the upgrade instead, you
can run

cancel
I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

to delete the temporary branch and switch back to main.
Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down
13 changes: 8 additions & 5 deletions unison-src/transcripts/idempotent/cycle-update-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ ping = 3

That's done. Now I'm making sure everything typechecks...

Some definitions don't typecheck with your changes. I've
updated the file scratch.u with the definitions that need
fixing. Once the file is compiling, try `update` again.
I couldn't complete the update, because some existing
definitions would no longer typecheck.

I've also switched you to a new branch update-main for this
work. On `update`, it will be merged back into main.
I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down
26 changes: 16 additions & 10 deletions unison-src/transcripts/idempotent/delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,15 @@ scratch/main> add
``` ucm :error
scratch/main> delete a b c

Some definitions depend on the ones you're trying to delete.
I've added them to scratch.u, where you can fix them or
comment them out. Once the file is compiling, run `update`.
I couldn't complete the delete, because some definitions are
still in use.

I've also switched you to a new branch update-main for this
work. On `update`, it will be merged back into main.
I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down Expand Up @@ -692,12 +695,15 @@ scratch/main> update
``` ucm :error
scratch/main> delete ping

Some definitions depend on the ones you're trying to delete.
I've added them to scratch.u, where you can fix them or
comment them out. Once the file is compiling, run `update`.
I couldn't complete the delete, because some definitions are
still in use.

I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

I've also switched you to a new branch update-main for this
work. On `update`, it will be merged back into main.
Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down
19 changes: 6 additions & 13 deletions unison-src/transcripts/idempotent/fix4482.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,14 @@ mybar = bar + bar

> upgrade foo0 foo1

I couldn't automatically upgrade foo0 to foo1. However, I've
added the definitions that need attention to the top of
scratch.u.
I couldn't automatically upgrade foo0 to foo1.

When you're done, you can run
I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

update

to merge your changes back into main and delete the temporary
branch. Or, if you decide to cancel the upgrade instead, you
can run

cancel

to delete the temporary branch and switch back to main.
Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down
13 changes: 8 additions & 5 deletions unison-src/transcripts/idempotent/update-suffixifies-properly.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ foo = +30

That's done. Now I'm making sure everything typechecks...

Some definitions don't typecheck with your changes. I've
updated the file scratch.u with the definitions that need
fixing. Once the file is compiling, try `update` again.
I couldn't complete the update, because some existing
definitions would no longer typecheck.

I've also switched you to a new branch update-main for this
work. On `update`, it will be merged back into main.
I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ foo = +5

That's done. Now I'm making sure everything typechecks...

Some definitions don't typecheck with your changes. I've
updated the file scratch.u with the definitions that need
fixing. Once the file is compiling, try `update` again.
I couldn't complete the update, because some existing
definitions would no longer typecheck.

I've also switched you to a new branch update-main for this
work. On `update`, it will be merged back into main.
I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down
13 changes: 8 additions & 5 deletions unison-src/transcripts/idempotent/update-test-watch-roundtrip.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ foo n = "hello, world!"

That's done. Now I'm making sure everything typechecks...

Some definitions don't typecheck with your changes. I've
updated the file scratch.u with the definitions that need
fixing. Once the file is compiling, try `update` again.
I couldn't complete the update, because some existing
definitions would no longer typecheck.

I've also switched you to a new branch update-main for this
work. On `update`, it will be merged back into main.
I've created a temporary branch and added the affected
definitions to scratch.u, where you can fix them up or remove
any that are obsolete.

Once you're happy with the results, use `update` to merge them
back into main, or `cancel` if you change your mind.
```

``` unison :added-by-ucm scratch.u
Expand Down
Loading