Skip to content

Commit

Permalink
Merge pull request #5243 from unisonweb/cp/remove-reset-root
Browse files Browse the repository at this point in the history
Remove reset-root, fix docs for reset
  • Loading branch information
aryairani authored Jul 22, 2024
2 parents 677266d + 5bedaf3 commit c4fc8d4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 57 deletions.
14 changes: 0 additions & 14 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions unison-cli/src/Unison/Codebase/Editor/Input.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
40 changes: 8 additions & 32 deletions unison-cli/src/Unison/CommandLine/InputPatterns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ module Unison.CommandLine.InputPatterns
renameTerm,
renameType,
reset,
resetRoot,
runScheme,
saveExecuteResult,
sfind,
Expand Down Expand Up @@ -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
Expand All @@ -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 ""
Expand Down Expand Up @@ -3502,7 +3479,6 @@ validInputs =
renameType,
moveAll,
reset,
resetRoot,
runScheme,
saveExecuteResult,
test,
Expand Down
4 changes: 2 additions & 2 deletions unison-cli/src/Unison/CommandLine/OutputMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
]
Expand Down
12 changes: 7 additions & 5 deletions unison-src/transcripts/help.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c4fc8d4

Please sign in to comment.