diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Delete.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Delete.hs index 3afd7fe539..d440a07b30 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Delete.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Delete.hs @@ -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")) currentNamespace <- Cli.getCurrentProjectRoot let currentNamespace0 = Branch.head currentNamespace @@ -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 @@ -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)] diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs index 20d29240f5..4239f2adf7 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs @@ -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 @@ -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) diff --git a/unison-cli/src/Unison/Codebase/Editor/Output.hs b/unison-cli/src/Unison/Codebase/Editor/Output.hs index ff771dde65..91b5f7225e 100644 --- a/unison-cli/src/Unison/Codebase/Editor/Output.hs +++ b/unison-cli/src/Unison/Codebase/Editor/Output.hs @@ -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 diff --git a/unison-cli/src/Unison/CommandLine/OutputMessages.hs b/unison-cli/src/Unison/CommandLine/OutputMessages.hs index 49a439d477..8751a8886e 100644 --- a/unison-cli/src/Unison/CommandLine/OutputMessages.hs +++ b/unison-cli/src/Unison/CommandLine/OutputMessages.hs @@ -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." @@ -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 @@ -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 = diff --git a/unison-src/transcripts/idempotent/cancel.md b/unison-src/transcripts/idempotent/cancel.md index e7c1eda061..6258bbdb19 100644 --- a/unison-src/transcripts/idempotent/cancel.md +++ b/unison-src/transcripts/idempotent/cancel.md @@ -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 @@ -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 diff --git a/unison-src/transcripts/idempotent/cycle-update-3.md b/unison-src/transcripts/idempotent/cycle-update-3.md index 06ee7e2a01..c29d4455ce 100644 --- a/unison-src/transcripts/idempotent/cycle-update-3.md +++ b/unison-src/transcripts/idempotent/cycle-update-3.md @@ -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 diff --git a/unison-src/transcripts/idempotent/delete.md b/unison-src/transcripts/idempotent/delete.md index 05e9bb1f3a..0f70daf1ea 100644 --- a/unison-src/transcripts/idempotent/delete.md +++ b/unison-src/transcripts/idempotent/delete.md @@ -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 @@ -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 diff --git a/unison-src/transcripts/idempotent/fix4482.md b/unison-src/transcripts/idempotent/fix4482.md index 2dc1b7b90d..de9ba7b04c 100644 --- a/unison-src/transcripts/idempotent/fix4482.md +++ b/unison-src/transcripts/idempotent/fix4482.md @@ -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 diff --git a/unison-src/transcripts/idempotent/update-suffixifies-properly.md b/unison-src/transcripts/idempotent/update-suffixifies-properly.md index 16bcac0f15..4be250ba0f 100644 --- a/unison-src/transcripts/idempotent/update-suffixifies-properly.md +++ b/unison-src/transcripts/idempotent/update-suffixifies-properly.md @@ -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 diff --git a/unison-src/transcripts/idempotent/update-term-with-dependent-to-different-type.md b/unison-src/transcripts/idempotent/update-term-with-dependent-to-different-type.md index de24b3e58f..b7692a96d7 100644 --- a/unison-src/transcripts/idempotent/update-term-with-dependent-to-different-type.md +++ b/unison-src/transcripts/idempotent/update-term-with-dependent-to-different-type.md @@ -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 diff --git a/unison-src/transcripts/idempotent/update-test-watch-roundtrip.md b/unison-src/transcripts/idempotent/update-test-watch-roundtrip.md index efedcd1c56..af604be2b0 100644 --- a/unison-src/transcripts/idempotent/update-test-watch-roundtrip.md +++ b/unison-src/transcripts/idempotent/update-test-watch-roundtrip.md @@ -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 diff --git a/unison-src/transcripts/idempotent/update-type-delete-constructor-with-dependent.md b/unison-src/transcripts/idempotent/update-type-delete-constructor-with-dependent.md index 9b12380537..c4c3c8998b 100644 --- a/unison-src/transcripts/idempotent/update-type-delete-constructor-with-dependent.md +++ b/unison-src/transcripts/idempotent/update-type-delete-constructor-with-dependent.md @@ -55,12 +55,15 @@ unique type Foo 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 diff --git a/unison-src/transcripts/idempotent/update-type-delete-record-field.md b/unison-src/transcripts/idempotent/update-type-delete-record-field.md index a9c7f6b81a..f2bfa495b4 100644 --- a/unison-src/transcripts/idempotent/update-type-delete-record-field.md +++ b/unison-src/transcripts/idempotent/update-type-delete-record-field.md @@ -69,12 +69,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 diff --git a/unison-src/transcripts/idempotent/update-type-with-dependent-term.md b/unison-src/transcripts/idempotent/update-type-with-dependent-term.md index 00a15ba8e4..7dd7b40858 100644 --- a/unison-src/transcripts/idempotent/update-type-with-dependent-term.md +++ b/unison-src/transcripts/idempotent/update-type-with-dependent-term.md @@ -50,12 +50,15 @@ unique type Foo = Bar Nat Nat 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 diff --git a/unison-src/transcripts/idempotent/update-type-with-dependent-type-to-different-kind.md b/unison-src/transcripts/idempotent/update-type-with-dependent-type-to-different-kind.md index a05c0d5b8f..b8ec22e246 100644 --- a/unison-src/transcripts/idempotent/update-type-with-dependent-type-to-different-kind.md +++ b/unison-src/transcripts/idempotent/update-type-with-dependent-type-to-different-kind.md @@ -47,12 +47,15 @@ unique type Foo a = Bar Nat a 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 diff --git a/unison-src/transcripts/idempotent/upgrade.md b/unison-src/transcripts/idempotent/upgrade.md index 5962a44c64..b327ebfba4 100644 --- a/unison-src/transcripts/idempotent/upgrade.md +++ b/unison-src/transcripts/idempotent/upgrade.md @@ -107,21 +107,14 @@ proj/main> update ``` ucm :error proj/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. + I couldn't automatically upgrade old to new. - 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 @@ -217,21 +210,14 @@ proj/main> update ``` ucm :error proj/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 - - update + I couldn't automatically upgrade old to new. - to merge your changes back into main and delete the temporary - branch. Or, if you decide to cancel the upgrade instead, 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. - 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 @@ -386,21 +372,14 @@ myproject/main> update ``` ucm :error myproject/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 - - 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 + I couldn't automatically upgrade old to new. - 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