Skip to content

Commit c4fc8d4

Browse files
authored
Merge pull request #5243 from unisonweb/cp/remove-reset-root
Remove reset-root, fix docs for reset
2 parents 677266d + 5bedaf3 commit c4fc8d4

File tree

5 files changed

+20
-57
lines changed

5 files changed

+20
-57
lines changed

unison-cli/src/Unison/Codebase/Editor/HandleInput.hs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,6 @@ loop e = do
262262
description <- inputDescription input
263263
_ <- Cli.updateAt description target (const newRoot)
264264
Cli.respond Success
265-
ResetRootI src0 ->
266-
Cli.time "reset-root" do
267-
newRoot <-
268-
case src0 of
269-
BranchAtSCH hash -> Cli.resolveShortCausalHash hash
270-
BranchAtPath path' -> Cli.expectBranchAtPath' path'
271-
BranchAtProjectPath pp -> Cli.getBranchFromProjectPath pp
272-
description <- inputDescription input
273-
pb <- getCurrentProjectBranch
274-
void $ Cli.updateProjectBranchRoot_ pb description (const newRoot)
275-
Cli.respond Success
276265
ForkLocalBranchI src0 dest0 -> do
277266
(srcb, branchEmpty) <-
278267
case src0 of
@@ -908,9 +897,6 @@ inputDescription input =
908897
let tgtText = into @Text tgt
909898
pure (" " <> tgtText)
910899
pure ("reset " <> hashTxt <> tgt)
911-
ResetRootI src0 -> do
912-
let src = into @Text src0
913-
pure ("reset-root " <> src)
914900
AliasTermI force src0 dest0 -> do
915901
src <- hhqs' src0
916902
dest <- ps' dest0

unison-cli/src/Unison/Codebase/Editor/Input.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,10 @@ data Input
125125
| DiffNamespaceI BranchId2 BranchId2 -- old new
126126
| PullI !PullSourceTarget !PullMode
127127
| PushRemoteBranchI PushRemoteBranchInput
128-
| ResetRootI BranchId
129128
| ResetI (BranchId2 {- namespace to reset it to -}) (Maybe UnresolvedProjectBranch {- ProjectBranch to reset -})
130-
| -- todo: Q: Does it make sense to publish to not-the-root of a Github repo?
131-
-- Does it make sense to fork from not-the-root of a Github repo?
132-
-- used in Welcome module to give directions to user
129+
-- todo: Q: Does it make sense to publish to not-the-root of a Github repo?
130+
-- Does it make sense to fork from not-the-root of a Github repo?
131+
| -- used in Welcome module to give directions to user
133132
CreateMessage (P.Pretty P.ColorText)
134133
| -- Change directory.
135134
SwitchBranchI Path'

unison-cli/src/Unison/CommandLine/InputPatterns.hs

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ module Unison.CommandLine.InputPatterns
100100
renameTerm,
101101
renameType,
102102
reset,
103-
resetRoot,
104103
runScheme,
105104
saveExecuteResult,
106105
sfind,
@@ -1661,11 +1660,14 @@ reset =
16611660
[ ("namespace, hash, or branch to reset to", Required, namespaceOrProjectBranchArg config),
16621661
("namespace to be reset", Optional, namespaceOrProjectBranchArg config)
16631662
]
1664-
( P.wrapColumn2
1665-
[ ("`reset #pvfd222s8n`", "reset the current namespace to the causal `#pvfd222s8n`"),
1666-
("`reset foo`", "reset the current namespace to that of the `foo` namespace."),
1667-
("`reset foo bar`", "reset the namespace `bar` to that of the `foo` namespace."),
1668-
("`reset #pvfd222s8n /topic`", "reset the branch `topic` of the current project to the causal `#pvfd222s8n`.")
1663+
( P.lines
1664+
[ P.wrapColumn2
1665+
[ ("`reset #pvfd222s8n`", "reset the current namespace to the hash `#pvfd222s8n`"),
1666+
("`reset foo`", "reset the current namespace to the state of the `foo` namespace."),
1667+
("`reset #pvfd222s8n /topic`", "reset the branch `topic` of the current project to the causal `#pvfd222s8n`.")
1668+
],
1669+
"",
1670+
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."
16691671
]
16701672
)
16711673
\case
@@ -1680,31 +1682,6 @@ reset =
16801682
branchInclusion = AllBranches
16811683
}
16821684

1683-
-- asBranch = tryInto @(ProjectAndBranch (Maybe ProjectName) ProjectBranchName) (Text.pack inputString)
1684-
1685-
resetRoot :: InputPattern
1686-
resetRoot =
1687-
InputPattern
1688-
"reset-root"
1689-
[]
1690-
I.Hidden
1691-
[("namespace or hash to reset to", Required, namespaceArg)]
1692-
( P.lines
1693-
[ "Deprecated because it's incompatible with projects. ⚠️ Warning, this command can cause codebase corruption.",
1694-
P.wrapColumn2
1695-
[ ( makeExample resetRoot [".foo"],
1696-
"Reset the root namespace (along with its history) to that of the `.foo` namespace. Deprecated"
1697-
),
1698-
( makeExample resetRoot ["#9dndk3kbsk13nbpeu"],
1699-
"Reset the root namespace (along with its history) to that of the namespace with hash `#9dndk3kbsk13nbpeu`."
1700-
)
1701-
]
1702-
]
1703-
)
1704-
$ \case
1705-
[src] -> Input.ResetRootI <$> handleBranchIdArg src
1706-
args -> wrongArgsLength "exactly one argument" args
1707-
17081685
pull :: InputPattern
17091686
pull =
17101687
pullImpl "pull" [] Input.PullWithHistory ""
@@ -3502,7 +3479,6 @@ validInputs =
35023479
renameType,
35033480
moveAll,
35043481
reset,
3505-
resetRoot,
35063482
runScheme,
35073483
saveExecuteResult,
35083484
test,

unison-cli/src/Unison/CommandLine/OutputMessages.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ notifyUser dir = \case
12901290
"to make an old namespace accessible again,"
12911291
),
12921292
(mempty, mempty),
1293-
( IP.makeExample IP.resetRoot [prettySCH prevSCH],
1294-
"to reset the root namespace and its history to that of the specified"
1293+
( IP.makeExample IP.reset [prettySCH prevSCH],
1294+
"to reset the current namespace and its history to that of the specified"
12951295
<> "namespace."
12961296
)
12971297
]

unison-src/transcripts/help.output.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,17 @@ scratch/main> help
683683
684684
reset
685685
`reset #pvfd222s8n` reset the current namespace to the
686-
causal `#pvfd222s8n`
687-
`reset foo` reset the current namespace to
688-
that of the `foo` namespace.
689-
`reset foo bar` reset the namespace `bar` to that
690-
of the `foo` namespace.
686+
hash `#pvfd222s8n`
687+
`reset foo` reset the current namespace to the
688+
state of the `foo` namespace.
691689
`reset #pvfd222s8n /topic` reset the branch `topic` of the
692690
current project to the causal
693691
`#pvfd222s8n`.
694692
693+
If you make a mistake using reset, consult the `branch.reflog`
694+
command and use another `reset` command to return to a
695+
previous state.
696+
695697
rewrite (or sfind.replace)
696698
`rewrite rule1` rewrites definitions in the latest scratch file.
697699

0 commit comments

Comments
 (0)