load alice and bob branches

This commit is contained in:
Travis Staton 2024-02-08 14:03:27 -05:00
parent 8de150bf32
commit b046acb857
No known key found for this signature in database
GPG Key ID: 431DD911A00DAE49
4 changed files with 35 additions and 2 deletions

View File

@ -78,6 +78,7 @@ dependencies:
- unison-core
- unison-core1
- unison-hash
- unison-merge
- unison-parser-typechecker
- unison-prelude
- unison-pretty-printer

View File

@ -8,6 +8,7 @@ module Unison.Cli.ProjectUtils
getCurrentProjectBranch,
getProjectBranchForPath,
expectCurrentProjectBranch,
expectProjectBranchByName,
projectPath,
projectBranchesPath,
projectBranchPath,
@ -125,6 +126,11 @@ getCurrentProjectBranch = do
path <- Cli.getCurrentPath
getProjectBranchForPath path
expectProjectBranchByName :: Sqlite.Project -> ProjectBranchName -> Cli Sqlite.ProjectBranch
expectProjectBranchByName project branchName =
Cli.runTransaction (Queries.loadProjectBranchByName (project ^. #projectId) branchName) & onNothingM do
Cli.returnEarly (LocalProjectBranchDoesntExist (ProjectAndBranch (project ^. #name) branchName))
getProjectBranchForPath :: Path.Absolute -> Cli (Maybe (ProjectAndBranch Sqlite.Project Sqlite.ProjectBranch, Path.Path))
getProjectBranchForPath path = do
case preview projectBranchPathPrism path of

View File

@ -3,8 +3,29 @@ module Unison.Codebase.Editor.HandleInput.Merge2
)
where
import Unison.Core.Project (ProjectBranchName)
import Control.Monad.Reader (ask)
import Unison.Prelude
import Control.Lens (Lens', over, view, (%=), (.=), (.~), (^.))
import Unison.Merge.Database (MergeDatabase(..), makeMergeDatabase)
import Unison.Cli.Monad (Cli)
import Unison.Cli.Monad qualified as Cli
import Unison.Project (ProjectAndBranch (..), ProjectBranchName)
import Unison.Cli.MonadUtils qualified as Cli
import Unison.Cli.ProjectUtils qualified as Cli
import Unison.Cli.TypeCheck (computeTypecheckingEnvironment, typecheckTerm)
import Unison.Cli.UniqueTypeGuidLookup qualified as Cli
import Unison.Merge.Diff qualified as Merge
handleMerge :: ProjectBranchName -> Cli ()
handleMerge = undefined
handleMerge bobBranchName = do
-- Load the current project branch ("alice"), and the branch from the same project to merge in ("bob")
(ProjectAndBranch project aliceProjectBranch, _path) <- Cli.expectCurrentProjectBranch
bobProjectBranch <- Cli.expectProjectBranchByName project bobBranchName
let projectBranches = Merge.TwoWay {alice = aliceProjectBranch, bob = bobProjectBranch}
let alicePath = Cli.projectBranchPath (ProjectAndBranch (project ^. #projectId) (aliceProjectBranch ^. #branchId))
let bobPath = Cli.projectBranchPath (ProjectAndBranch (project ^. #projectId) (bobProjectBranch ^. #branchId))
-- Create a bunch of cached database lookup functions
Cli.Env {codebase} <- ask
db@MergeDatabase {loadCausal} <- makeMergeDatabase codebase
undefined

View File

@ -239,6 +239,7 @@ library
, unison-core
, unison-core1
, unison-hash
, unison-merge
, unison-parser-typechecker
, unison-prelude
, unison-pretty-printer
@ -378,6 +379,7 @@ executable cli-integration-tests
, unison-core
, unison-core1
, unison-hash
, unison-merge
, unison-parser-typechecker
, unison-prelude
, unison-pretty-printer
@ -512,6 +514,7 @@ executable transcripts
, unison-core
, unison-core1
, unison-hash
, unison-merge
, unison-parser-typechecker
, unison-prelude
, unison-pretty-printer
@ -652,6 +655,7 @@ executable unison
, unison-core
, unison-core1
, unison-hash
, unison-merge
, unison-parser-typechecker
, unison-prelude
, unison-pretty-printer
@ -795,6 +799,7 @@ test-suite cli-tests
, unison-core
, unison-core1
, unison-hash
, unison-merge
, unison-parser-typechecker
, unison-prelude
, unison-pretty-printer