Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Dec 3, 2024
1 parent 8c68bb7 commit 036793e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
17 changes: 12 additions & 5 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput/Merge2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,25 @@ doMerge info = do
Cli.runTransactionWithRollback2 (\rollback -> Right <$> action (rollback . Left))
& onLeftM (done . Output.ConflictedDefn "merge")

libdeps3 <- Cli.runTransaction (loadLibdeps branches)

let blob0 = Merge.makeMergeblob0 nametrees3 libdeps3

names3 :: Merge.ThreeWay Names <- do
let causalHashes = Merge.TwoOrThreeWay {alice = info.alice.causalHash, bob = info.bob.causalHash, lca = info.lca.causalHash}
let causalHashes =
Merge.TwoOrThreeWay
{ alice = info.alice.causalHash,
bob = info.bob.causalHash,
lca = info.lca.causalHash
}
branches <- for causalHashes \ch -> do
liftIO (Codebase.getBranchForHash env.codebase ch) >>= \case
Nothing -> done (Output.CouldntLoadBranch ch)
Just b -> pure b
let names = fmap (Branch.toNames . Branch.head) branches
pure Merge.ThreeWay {alice = names.alice, bob = names.bob, lca = fromMaybe mempty names.lca}

libdeps3 <- Cli.runTransaction (loadLibdeps branches)

let blob0 = Merge.makeMergeblob0 nametrees3 libdeps3
respondRegion (Output.Literal "Loading definitions...")

-- Hydrate
hydratedDefns ::
Expand All @@ -270,7 +277,7 @@ doMerge info = do
in bimap f g <$> blob0.defns
)

respondRegion (Output.Literal "Computing diff between branches...")
respondRegion (Output.Literal "Computing diffs...")

blob1 <-
Merge.makeMergeblob1 blob0 names3 hydratedDefns & onLeft \case
Expand Down
9 changes: 3 additions & 6 deletions unison-merge/src/Unison/Merge/Diff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,8 @@ humanizeDiffs ::
TwoWay (DefnsF2 (Map Name) Updated Referent TypeReference) ->
TwoWay (DefnsF2 (Map Name) HumanDiffOp Referent TypeReference)
humanizeDiffs names3 diffs propagatedUpdates =
zipWithF3
nameRelations
diffs
propagatedUpdates
\relation diffOps propagatedUpdates -> Defns.zipDefnsWith4 computeHumanDiffOp computeHumanDiffOp lcaRelation relation diffOps propagatedUpdates
zipWithF3 nameRelations diffs propagatedUpdates \relation diffOps propagatedUpdates ->
Defns.zipDefnsWith4 computeHumanDiffOp computeHumanDiffOp lcaRelation relation diffOps propagatedUpdates
where
zipWithF3 :: (Zip.Zip f) => f a -> f b -> f c -> (a -> b -> c -> d) -> f d
zipWithF3 a b c f = Zip.zipWith (\(x, y) z -> f x y z) (Zip.zip a b) c
Expand All @@ -148,7 +145,7 @@ humanizeDiffs names3 diffs propagatedUpdates =
go :: These (DiffOp (Synhashed ref)) (Updated ref) -> (HumanDiffOp ref)
go = \case
This diff -> humanizeDiffOp (Synhashed.value <$> diff)
That updated -> (HumanDiffOp'PropagatedUpdate updated)
That updated -> HumanDiffOp'PropagatedUpdate updated
These diff updated -> error (reportBug "E488729" ("The impossible happened, an update in merge was detected as both a propagated AND core update " ++ show diff ++ " and " ++ show updated))

humanizeDiffOp :: DiffOp ref -> HumanDiffOp ref
Expand Down

0 comments on commit 036793e

Please sign in to comment.