diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs index 7f830ec2d7..e85879cc4a 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs @@ -262,17 +262,6 @@ loop e = do description <- inputDescription input _ <- Cli.updateAt description target (const newRoot) Cli.respond Success - ResetRootI src0 -> - Cli.time "reset-root" do - newRoot <- - case src0 of - BranchAtSCH hash -> Cli.resolveShortCausalHash hash - BranchAtPath path' -> Cli.expectBranchAtPath' path' - BranchAtProjectPath pp -> Cli.getBranchFromProjectPath pp - description <- inputDescription input - pb <- getCurrentProjectBranch - void $ Cli.updateProjectBranchRoot_ pb description (const newRoot) - Cli.respond Success ForkLocalBranchI src0 dest0 -> do (srcb, branchEmpty) <- case src0 of @@ -908,9 +897,6 @@ inputDescription input = let tgtText = into @Text tgt pure (" " <> tgtText) pure ("reset " <> hashTxt <> tgt) - ResetRootI src0 -> do - let src = into @Text src0 - pure ("reset-root " <> src) AliasTermI force src0 dest0 -> do src <- hhqs' src0 dest <- ps' dest0 diff --git a/unison-cli/src/Unison/Codebase/Editor/Input.hs b/unison-cli/src/Unison/Codebase/Editor/Input.hs index 427c549507..d0bc3ae9d2 100644 --- a/unison-cli/src/Unison/Codebase/Editor/Input.hs +++ b/unison-cli/src/Unison/Codebase/Editor/Input.hs @@ -125,11 +125,10 @@ data Input | DiffNamespaceI BranchId2 BranchId2 -- old new | PullI !PullSourceTarget !PullMode | PushRemoteBranchI PushRemoteBranchInput - | ResetRootI BranchId | 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 + -- 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. SwitchBranchI Path' diff --git a/unison-cli/src/Unison/CommandLine/InputPatterns.hs b/unison-cli/src/Unison/CommandLine/InputPatterns.hs index 159dac83a7..6dc5581f62 100644 --- a/unison-cli/src/Unison/CommandLine/InputPatterns.hs +++ b/unison-cli/src/Unison/CommandLine/InputPatterns.hs @@ -100,7 +100,6 @@ module Unison.CommandLine.InputPatterns renameTerm, renameType, reset, - resetRoot, runScheme, saveExecuteResult, sfind, @@ -1661,11 +1660,14 @@ reset = [ ("namespace, hash, or branch to reset to", Required, namespaceOrProjectBranchArg config), ("namespace to be reset", Optional, namespaceOrProjectBranchArg config) ] - ( P.wrapColumn2 - [ ("`reset #pvfd222s8n`", "reset the current namespace to the causal `#pvfd222s8n`"), - ("`reset foo`", "reset the current namespace to that of the `foo` namespace."), - ("`reset foo bar`", "reset the namespace `bar` to that of the `foo` namespace."), - ("`reset #pvfd222s8n /topic`", "reset the branch `topic` of the current project to the causal `#pvfd222s8n`.") + ( P.lines + [ P.wrapColumn2 + [ ("`reset #pvfd222s8n`", "reset the current namespace to the hash `#pvfd222s8n`"), + ("`reset foo`", "reset the current namespace to the state of the `foo` namespace."), + ("`reset #pvfd222s8n /topic`", "reset the branch `topic` of the current project to the causal `#pvfd222s8n`.") + ], + "", + P.wrap $ "If you make a mistake using reset, consult the " <> makeExample' branchReflog <> " command and use another " <> makeExample' reset <> " command to return to a previous state." ] ) \case @@ -1680,31 +1682,6 @@ reset = branchInclusion = AllBranches } --- asBranch = tryInto @(ProjectAndBranch (Maybe ProjectName) ProjectBranchName) (Text.pack inputString) - -resetRoot :: InputPattern -resetRoot = - InputPattern - "reset-root" - [] - I.Hidden - [("namespace or hash to reset to", Required, namespaceArg)] - ( P.lines - [ "Deprecated because it's incompatible with projects. ⚠️ Warning, this command can cause codebase corruption.", - P.wrapColumn2 - [ ( makeExample resetRoot [".foo"], - "Reset the root namespace (along with its history) to that of the `.foo` namespace. Deprecated" - ), - ( makeExample resetRoot ["#9dndk3kbsk13nbpeu"], - "Reset the root namespace (along with its history) to that of the namespace with hash `#9dndk3kbsk13nbpeu`." - ) - ] - ] - ) - $ \case - [src] -> Input.ResetRootI <$> handleBranchIdArg src - args -> wrongArgsLength "exactly one argument" args - pull :: InputPattern pull = pullImpl "pull" [] Input.PullWithHistory "" @@ -3502,7 +3479,6 @@ validInputs = renameType, moveAll, reset, - resetRoot, runScheme, saveExecuteResult, test, diff --git a/unison-cli/src/Unison/CommandLine/OutputMessages.hs b/unison-cli/src/Unison/CommandLine/OutputMessages.hs index 473e3d01c6..d061f37f54 100644 --- a/unison-cli/src/Unison/CommandLine/OutputMessages.hs +++ b/unison-cli/src/Unison/CommandLine/OutputMessages.hs @@ -1290,8 +1290,8 @@ notifyUser dir = \case "to make an old namespace accessible again," ), (mempty, mempty), - ( IP.makeExample IP.resetRoot [prettySCH prevSCH], - "to reset the root namespace and its history to that of the specified" + ( IP.makeExample IP.reset [prettySCH prevSCH], + "to reset the current namespace and its history to that of the specified" <> "namespace." ) ] diff --git a/unison-src/transcripts/help.output.md b/unison-src/transcripts/help.output.md index b8d12061e4..aad724347c 100644 --- a/unison-src/transcripts/help.output.md +++ b/unison-src/transcripts/help.output.md @@ -683,15 +683,17 @@ scratch/main> help reset `reset #pvfd222s8n` reset the current namespace to the - causal `#pvfd222s8n` - `reset foo` reset the current namespace to - that of the `foo` namespace. - `reset foo bar` reset the namespace `bar` to that - of the `foo` namespace. + hash `#pvfd222s8n` + `reset foo` reset the current namespace to the + state of the `foo` namespace. `reset #pvfd222s8n /topic` reset the branch `topic` of the current project to the causal `#pvfd222s8n`. + If you make a mistake using reset, consult the `branch.reflog` + command and use another `reset` command to return to a + previous state. + rewrite (or sfind.replace) `rewrite rule1` rewrites definitions in the latest scratch file.