Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove update.old #5058

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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
18 changes: 1 addition & 17 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import Unison.Codebase.Editor.HandleInput.ShowDefinition (showDefinitions)
import Unison.Codebase.Editor.HandleInput.TermResolution (resolveMainRef)
import Unison.Codebase.Editor.HandleInput.Tests qualified as Tests
import Unison.Codebase.Editor.HandleInput.UI (openUI)
import Unison.Codebase.Editor.HandleInput.Update (doSlurpAdds, handleUpdate)
import Unison.Codebase.Editor.HandleInput.Update (doSlurpAdds)
import Unison.Codebase.Editor.HandleInput.Update2 (handleUpdate2)
import Unison.Codebase.Editor.HandleInput.Upgrade (handleUpgrade)
import Unison.Codebase.Editor.Input
Expand Down Expand Up @@ -733,15 +733,7 @@ loop e = do
currentNames <- Branch.toNames <$> Cli.getCurrentBranch0
let sr = Slurp.slurpFile uf vars Slurp.AddOp currentNames
previewResponse sourceName sr uf
UpdateI optionalPatch requestedNames -> handleUpdate input optionalPatch requestedNames
Update2I -> handleUpdate2
PreviewUpdateI requestedNames -> do
(sourceName, _) <- Cli.expectLatestFile
uf <- Cli.expectLatestTypecheckedFile
let vars = Set.map Name.toVar requestedNames
currentNames <- Branch.toNames <$> Cli.getCurrentBranch0
let sr = Slurp.slurpFile uf vars Slurp.UpdateOp currentNames
previewResponse sourceName sr uf
TodoI patchPath branchPath' -> do
patch <- Cli.getPatchAt (fromMaybe Cli.defaultPatchPath patchPath)
branchPath <- Cli.resolvePath' branchPath'
Expand Down Expand Up @@ -1053,13 +1045,6 @@ inputDescription input =
DeleteTarget'ProjectBranch _ -> wat
DeleteTarget'Project _ -> wat
AddI _selection -> pure "add"
UpdateI p0 _selection -> do
p <-
case p0 of
NoPatch -> pure ".nopatch"
DefaultPatch -> (" " <>) <$> ps' Cli.defaultPatchPath
UsePatch p0 -> (" " <>) <$> ps' p0
pure ("update.old" <> p)
Update2I -> pure ("update")
UndoI {} -> pure "undo"
ExecuteI s args -> pure ("execute " <> Text.unwords (HQ.toText s : fmap Text.pack args))
Expand Down Expand Up @@ -1120,7 +1105,6 @@ inputDescription input =
PopBranchI {} -> wat
PreviewAddI {} -> wat
PreviewMergeLocalBranchI {} -> wat
PreviewUpdateI {} -> wat
ProjectCreateI {} -> wat
ProjectRenameI {} -> wat
ProjectSwitchI {} -> wat
Expand Down
621 changes: 3 additions & 618 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput/Update.hs

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions unison-cli/src/Unison/Codebase/Editor/Input.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ data Input
| ClearI
| AddI (Set Name)
| PreviewAddI (Set Name)
| UpdateI OptionalPatch (Set Name)
| Update2I
| PreviewUpdateI (Set Name)
| TodoI (Maybe PatchPath) Path'
| UndoI
| -- First `Maybe Int` is cap on number of results, if any
Expand Down
85 changes: 0 additions & 85 deletions unison-cli/src/Unison/CommandLine/InputPatterns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ module Unison.CommandLine.InputPatterns
names,
namespaceDependencies,
previewAdd,
previewUpdate,
printVersion,
projectCreate,
projectCreateEmptyInputPattern,
Expand Down Expand Up @@ -114,8 +113,6 @@ module Unison.CommandLine.InputPatterns
up,
update,
updateBuiltins,
updateOld,
updateOldNoPatch,
upgrade,
upgradeCommitInputPattern,
view,
Expand Down Expand Up @@ -829,85 +826,6 @@ update =
_ -> Left $ I.help update
}

updateOldNoPatch :: InputPattern
updateOldNoPatch =
InputPattern
"update.old.nopatch"
[]
I.Visible
[("definition", ZeroPlus, noCompletionsArg)]
( P.wrap
( makeExample' updateOldNoPatch
<> "works like"
<> P.group (makeExample' updateOld <> ",")
<> "except it doesn't add a patch entry for any updates. "
<> "Use this when you want to make changes to definitions without "
<> "pushing those changes to dependents beyond your codebase. "
<> "An example is when updating docs, or when updating a term you "
<> "just added."
)
<> P.wrapColumn2
[ ( makeExample' updateOldNoPatch,
"updates all definitions in the .u file."
),
( makeExample updateOldNoPatch ["foo", "bar"],
"updates `foo`, `bar`, and their dependents from the .u file."
)
]
)
$ fmap (Input.UpdateI Input.NoPatch . Set.fromList) . traverse handleNameArg

updateOld :: InputPattern
updateOld =
InputPattern
"update.old"
[]
I.Visible
[("patch", Optional, patchArg), ("definition", ZeroPlus, noCompletionsArg)]
( P.wrap
( makeExample' updateOld
<> "works like"
<> P.group (makeExample' add <> ",")
<> "except that if a definition in the file has the same name as an"
<> "existing definition, the name gets updated to point to the new"
<> "definition. If the old definition has any dependents, `update` will"
<> "add those dependents to a refactoring session, specified by an"
<> "optional patch."
)
<> P.wrapColumn2
[ ( makeExample' updateOld,
"adds all definitions in the .u file, noting replacements in the"
<> "default patch for the current namespace."
),
( makeExample updateOld ["<patch>"],
"adds all definitions in the .u file, noting replacements in the"
<> "specified patch."
),
( makeExample updateOld ["<patch>", "foo", "bar"],
"adds `foo`, `bar`, and their dependents from the .u file, noting"
<> "any replacements into the specified patch."
)
]
)
\case
patchStr : ws ->
Input.UpdateI . Input.UsePatch <$> handleSplit'Arg patchStr <*> fmap Set.fromList (traverse handleNameArg ws)
[] -> Right $ Input.UpdateI Input.DefaultPatch mempty

previewUpdate :: InputPattern
previewUpdate =
InputPattern
"update.old.preview"
[]
I.Visible
[("definition", ZeroPlus, noCompletionsArg)]
( "`update.old.preview` previews updates to the codebase from the most "
<> "recently typechecked file. This command only displays cached "
<> "typechecking results. Use `load` to reparse & typecheck the file if "
<> "the context has changed."
)
$ fmap (Input.PreviewUpdateI . Set.fromList) . traverse handleNameArg

view :: InputPattern
view =
InputPattern
Expand Down Expand Up @@ -3296,7 +3214,6 @@ validInputs =
names True, -- names.global
namespaceDependencies,
previewAdd,
previewUpdate,
printVersion,
projectCreate,
projectCreateEmptyInputPattern,
Expand Down Expand Up @@ -3327,8 +3244,6 @@ validInputs =
up,
update,
updateBuiltins,
updateOld,
updateOldNoPatch,
upgrade,
upgradeCommitInputPattern,
view,
Expand Down
1 change: 0 additions & 1 deletion unison-cli/src/Unison/CommandLine/OutputMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,6 @@ notifyUser dir = \case
SlurpOutput input ppe s ->
let isPast = case input of
Input.AddI {} -> True
Input.UpdateI {} -> True
Input.SaveExecuteResultI {} -> True
_ -> False
in pure $ SlurpResult.pretty isPast ppe s
Expand Down
20 changes: 6 additions & 14 deletions unison-src/transcripts/ability-term-conflicts-on-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ thing : '{Channels} ()
thing _ = send 1
```

These should fail with a term/ctor conflict since we exclude the ability from the update.
We should be able to update everything at once.

```ucm:error
.ns> update.old patch Channels.send
.ns> update.old patch thing
```ucm
.ns> update
```

If however, `Channels.send` and `thing` _depend_ on `Channels`, updating them should succeed since it pulls in the ability as a dependency.
If `Channels.send` and `thing` _depend_ on `Channels`, updating them should succeed since it pulls in the ability as a dependency.

```unison
unique ability Channels where
Expand All @@ -53,17 +52,10 @@ thing : '{Channels} ()
thing _ = send 1
```

These updates should succeed since `Channels` is a dependency.

```ucm
.ns> update.old.preview patch Channels.send
.ns> update.old.preview patch thing
```

We should also be able to successfully update the whole thing.
We should be able to successfully update the whole thing.

```ucm
.ns> update.old
.ns> update
```

# Constructor-term conflict
Expand Down
68 changes: 11 additions & 57 deletions unison-src/transcripts/ability-term-conflicts-on-update.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,18 @@ thing _ = send 1
ability Channels

```
These should fail with a term/ctor conflict since we exclude the ability from the update.
We should be able to update everything at once.

```ucm
.ns> update.old patch Channels.send
.ns> update

x These definitions failed:

Reason
term/ctor collision Channels.send : a -> ()

Tip: Use `help filestatus` to learn more.
Okay, I'm searching the branch for code that needs to be
updated...

.ns> update.old patch thing

⍟ I've added these definitions:

Channels.send : a -> ()
thing : '{Channels} ()

⍟ I've updated these names to your new definition:

ability Channels
Done.

```
If however, `Channels.send` and `thing` _depend_ on `Channels`, updating them should succeed since it pulls in the ability as a dependency.
If `Channels.send` and `thing` _depend_ on `Channels`, updating them should succeed since it pulls in the ability as a dependency.

```unison
unique ability Channels where
Expand Down Expand Up @@ -119,48 +106,15 @@ thing _ = send 1
thing : '{Channels} ()

```
These updates should succeed since `Channels` is a dependency.
We should be able to successfully update the whole thing.

```ucm
.ns> update.old.preview patch Channels.send

I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:

⊡ Previously added definitions will be ignored: Channels

⍟ These names already exist. You can `update` them to your
new definition:

Channels.send : a ->{Channels} ()

.ns> update.old.preview patch thing

I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:

⊡ Previously added definitions will be ignored: Channels

⍟ These names already exist. You can `update` them to your
new definition:

Channels.send : a ->{Channels} ()
thing : '{Channels} ()
.ns> update

```
We should also be able to successfully update the whole thing.

```ucm
.ns> update.old
Okay, I'm searching the branch for code that needs to be
updated...

⊡ Ignored previously added definitions: Channels

⍟ I've updated these names to your new definition:

Channels.send : a ->{Channels} ()
thing : '{Channels} ()
Done.

```
# Constructor-term conflict
Expand Down
9 changes: 7 additions & 2 deletions unison-src/transcripts/cycle-update-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ ping : Nat
ping = 3
```

```ucm
.> update.old
Updating only part of a cycle should bring the rest of the cycle into scope:

```ucm:error
.> update
```

```
.> view ping pong
```
36 changes: 24 additions & 12 deletions unison-src/transcripts/cycle-update-3.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,33 @@ ping = 3
ping : Nat

```
Updating only part of a cycle should bring the rest of the cycle into scope:

```ucm
.> update.old
.> update

⍟ I've updated these names to your new definition:

ping : Nat
Okay, I'm searching the branch for code that needs to be
updated...

.> view ping pong
That's done. Now I'm making sure everything typechecks...

ping : Nat
ping = 3

pong : 'Nat
pong _ =
use Nat +
!#4t465jk908.1 + 2
Typechecking failed. I've updated your scratch file with the
definitions that need fixing. Once the file is compiling, try
`update` again.

```
```unison:added-by-ucm scratch.u
ChrisPenner marked this conversation as resolved.
Show resolved Hide resolved
pong : 'Nat
pong _ =
use Nat +
!ping + 2

ping : Nat
ping = 3
```

```
.> view ping pong

```

2 changes: 1 addition & 1 deletion unison-src/transcripts/cycle-update-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ clang _ = !pong + 3
```

```ucm
.> update.old ping
.> update
.> view ping pong clang
```
Loading