-
Notifications
You must be signed in to change notification settings - Fork 266
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
[WIP] Project Roots #5041
Draft
ChrisPenner
wants to merge
164
commits into
trunk
Choose a base branch
from
cp/project-root
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] Project Roots #5041
Changes from 157 commits
Commits
Show all changes
164 commits
Select commit
Hold shift + click to select a range
73145db
Add Location pt 2
ChrisPenner fe751e1
Remove direct access to root branch
ChrisPenner 12b3107
Add migration to move project branches to sqlite
ChrisPenner 39f065e
Propagate root branch accessors
ChrisPenner 2c64c6a
Checkpoint
ChrisPenner 1a15c3f
Set currentProjectPath in SQLite
ChrisPenner dca8431
Add getShallowProjectRootByNames
ChrisPenner 2b50419
Rewrite BranchRelativePaths machinery
ChrisPenner 5a11d23
Resolve merge conflicts
ChrisPenner 29fd307
Checkpoint
ChrisPenner 2c98ad1
Checkpoint
ChrisPenner 467dee1
Checkpoint
ChrisPenner 457ca14
Allow updating branch heads
ChrisPenner 9de134f
Merge deletion of git commands into project-root
ChrisPenner 9756ac8
WIP
ChrisPenner 8377f68
merge trunk
ChrisPenner 965f36f
Merge trunk
ChrisPenner 33c42db
Fix weird added file
ChrisPenner 0d80992
Remove root branch accessors from codebase
ChrisPenner 216967f
Use onCreate hook to initialize projects
ChrisPenner 1d906b3
Clean up uses of root in Codebase, kill the root branch cache
ChrisPenner 3361010
Fix up uses of root branch in Backend
ChrisPenner 2e754a8
Propagate lack of root branch combinators to local Codebase Server
ChrisPenner 2773153
Fix argparse for running 'main' within project
ChrisPenner 33458a8
Fix LSP to work with projects
ChrisPenner 77af994
Merge trunk
ChrisPenner 4e2ccf2
Fix up some more root branch gets
ChrisPenner 138c6e9
Fix up input patterns for project branch args
ChrisPenner 3267a3e
Fix up Merge2
ChrisPenner 9bf5d6f
Fix up MonadUtils
ChrisPenner c3a2dfb
Don't include causalHashId in ProjectBranch
ChrisPenner ecba936
Fix up project branch deletes
ChrisPenner f42d57f
Fix up MonadUtils again
ChrisPenner 5ad808c
Update MoveTerm, MoveType, MoveBranch
ChrisPenner 36c63e4
Merge trunk
ChrisPenner ce1c221
Fixup MoveAll
ChrisPenner a46321f
Fix up Branch.hs module
ChrisPenner 0016706
Pull cleanup
ChrisPenner 0799264
Remove NoSync primitive usages in Update/Propagate
ChrisPenner 07f8774
Remove nosync usages from AddRun
ChrisPenner 14bd801
Remove NoSync primitive usages
ChrisPenner 8b5859c
Remove NoSync primitives
ChrisPenner 87bd969
Inline nosync versions into their regular forms so people aren't temp…
ChrisPenner 9f7b825
Tweaks
ChrisPenner 1e67634
Merge removal of nosync with project-root
ChrisPenner 6518e3f
Deleting a bunch of stuff to do with push/pull loose code
ChrisPenner 3f44257
Better project-branch centric utils
ChrisPenner 276758f
More command cleanups
ChrisPenner 3aa8fcc
Fix up Project Clone
ChrisPenner c42d128
Fix up ProjectCreate
ChrisPenner b663d44
Finish cleaning up create branch
ChrisPenner 16dea7a
Fix up Merge
ChrisPenner e24a5ee
More command fixups
ChrisPenner e65f6e1
Remove ability to push loose code paths (local or on share)
ChrisPenner 9c17d14
Remove ability to push to loose code or pull into loose code.
ChrisPenner 5b0045d
Fix ReleaseDraft
ChrisPenner 9936a02
Fix Upgrade
ChrisPenner 1e4627b
Fix update.old
ChrisPenner 7b5845f
Fix AddRun
ChrisPenner b1ad159
Fix up Pull
ChrisPenner 0b16a7c
Fixup BranchId
ChrisPenner bcc39d8
Remerge trunk
ChrisPenner 7a4ae28
Remerge trunk again
ChrisPenner 7274361
Fix up Pull and output messages
ChrisPenner a7d455c
Fix CommitUpgrade
ChrisPenner 87c9d5b
automatically run ormolu
ChrisPenner 1faba84
Don't expose dangerous primitives for setting project root
ChrisPenner 6d78dab
Fix up most imports in HandleInput
ChrisPenner b76e559
Fix projectbranch resolve rename
ChrisPenner 591d72c
Resolve imports in HandleInput
ChrisPenner 18cde10
WIP
ChrisPenner 8138e61
toText and output munging
ChrisPenner 48371c0
Propagate ProjectPath into CLI Main
ChrisPenner b876ab1
Solve branch conflict
ChrisPenner 91527b6
Merge trunk
ChrisPenner 2863b66
Convert transcript parser to be project based
ChrisPenner 23fd0a0
Allow passing project and branch as starting path
ChrisPenner 7298bbe
Revive causal hash signal in LSP
ChrisPenner 7aabcf5
Fix up Execute
ChrisPenner 95fd37a
Bootstrap scratch project in migration
ChrisPenner 203f2ce
Add better callstacks to sqlite exceptions.
ChrisPenner d53f267
Create scratch project during codebase creation
ChrisPenner 6ba3e87
Add to project reflog
ChrisPenner cdf10c9
Migration to port project branches to have causal ids.
ChrisPenner 6d8605e
Merge trunk
ChrisPenner 6c11576
Split migrations into separate transactions
ChrisPenner ff2c270
Fix up a buncha sql
ChrisPenner f192edb
Fix up migration quirks
ChrisPenner cc441e9
Fix projectpath updating in memory branch
ChrisPenner 1c186d4
Merge trunk into cp/project-root
ChrisPenner 60f99c2
Insert scratch branch after adding the causal hash table
ChrisPenner 4261902
Fix order of operations on codebase creation
ChrisPenner 4fb0077
Don't create new projects on each transcript, just use the current pr…
ChrisPenner 5a6fe20
Migrate loose code into legacy project
ChrisPenner 8c2b6cf
Remove now unused namespaceRoot combinators
ChrisPenner 1cbac28
Fix unique type guid generation
ChrisPenner 1f34de9
Swap stepAt combinators to use project paths
ChrisPenner dadc4e4
Merge trunk and resolve basic conflicts
ChrisPenner 0b8548f
Delete some out of date bits of transcripts
ChrisPenner 38d60e7
Switch project before deleting it
ChrisPenner fce12cb
Work on fixing some transcripts for projects
ChrisPenner 5f78557
Solve conflicts
ChrisPenner 2002a56
Remove loose code support from api
ChrisPenner 724dea4
Update api transcripts
ChrisPenner d93b5de
Update paths in branch-relative-path.md
ChrisPenner fbd7bb9
Update 'bug-strange-closure.md'
ChrisPenner 081f344
Fix delete.md
ChrisPenner 99bad76
Allow hashes or branches in diff.namespace
ChrisPenner b636068
Partially update diff-namespace
ChrisPenner 6f19a87
Update merge.md and fix5129
ChrisPenner 983fb05
Port move-namespace to projects
ChrisPenner 55ad236
Update name-selection transcript
ChrisPenner e66b315
Partially translate names.md
ChrisPenner 498e898
Update namespace-dependencies
ChrisPenner 9af023b
Fixup resolution-failures.md
ChrisPenner c095003
Fix up tab-completion transcripts for project roots
ChrisPenner 478545e
Rewrite view.md, still failing
ChrisPenner 7dbb365
Convert diff-namespaces.md to project-root
ChrisPenner 5c675df
Revive ability to delete root namespace
ChrisPenner 6ae9f8b
Fix behaviour of branch command
ChrisPenner eaf233c
automatically run ormolu
ChrisPenner e9f2aa3
Un-ignore transcript-parser-commands.md and fix it.
ChrisPenner 2331c16
Mostly Fix up deleting the branch you're on
ChrisPenner cc07b63
Merge trunk
ChrisPenner 1dab376
Fix behaviour of deleting last project or branch
ChrisPenner a7820fe
Deprecate root reflog behaviour in favour of project/branch reflogs
ChrisPenner 7148685
Implement DB combinators for project and branch reflogs
ChrisPenner 7f57612
More WIP on reflog commands
ChrisPenner 2db50ad
Specialize 'fromHash' to CausalHash
ChrisPenner 31874bd
Add reflog.global command
ChrisPenner 8a405e0
Update reflog command WIP
ChrisPenner 49258bc
Merge trunk
ChrisPenner dd81f0a
disable names.global transcript for now
ChrisPenner 4c89423
Rerun transcripts
ChrisPenner d0002b4
Disable view.global transcript for now
ChrisPenner 424b43b
Fix up reset transcripts for projects
ChrisPenner 6021a3a
automatically run ormolu
ChrisPenner 927b76b
Get tests building again.
ChrisPenner c431d35
Fix integration-tests
ChrisPenner 69edcef
Fix up round-trip tests
ChrisPenner 0cea9d6
Merge trunk, clean up random extra files
ChrisPenner 5e775cc
Improve docs
ChrisPenner c625e47
Add undo.md transcript
ChrisPenner 66d9b76
Ignore more scratchfiles
ChrisPenner e506b00
No in-memory branch in loop-state
ChrisPenner d8e34c2
Write new Transactional Signal type
ChrisPenner 4254a51
Update LSP to listen for changes
ChrisPenner c156ba7
Add isTranscriptTest to Cli.Env
ChrisPenner 6fe6d67
Omit times from project reflogs
ChrisPenner 736ccf1
Merge trunk
ChrisPenner 951f318
preload branches into the branch cache when switching projects
ChrisPenner 09ecc74
Fix test build
ChrisPenner 1543160
Revive move-branch confirmations
ChrisPenner 67a41cd
Docs and transcripts
ChrisPenner 1cd3f3c
Fix move-namespace transcript
ChrisPenner fa6c59e
Fix merge transcript
ChrisPenner f725bf2
Fix names transcript
ChrisPenner bf20459
Typo
ChrisPenner 2f4e57d
Fix Upgrade
ChrisPenner f382ef1
Attempt to fix up update.old
ChrisPenner a455180
No leading dot on brps
ChrisPenner 0cd3cd1
Merge branch 'trunk' into cp/project-root
aryairani 7113005
Remerge remote
ChrisPenner 4045805
Merge trunk
ChrisPenner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
# Unison | ||
.unison* | ||
test-output | ||
transcript-* | ||
scratch.u | ||
unisonLocal.zip | ||
*.uc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAICT there's no reason we'd want to keep |
||
# Ignore all scratch files... | ||
*.u | ||
# Except those in unison-src | ||
!unison-src/**/*.u | ||
# And integration tests | ||
!unison-cli-integration/integration-tests/IntegrationTests/**/*.u | ||
|
||
# Auto-generated | ||
jit-tests.md | ||
|
@@ -19,6 +24,7 @@ dist-newstyle | |
# GHC | ||
*.hie | ||
*.prof | ||
*.prof.html | ||
/.direnv/ | ||
/.envrc | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
module U.Codebase.Sqlite.Operations | ||
( -- * branches | ||
saveRootBranch, | ||
loadRootCausalHash, | ||
expectRootCausalHash, | ||
expectRootCausal, | ||
expectRootBranchHash, | ||
Comment on lines
-3
to
-7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removes the ability to access to root namespace entirely. |
||
loadCausalHashAtPath, | ||
expectCausalHashAtPath, | ||
loadCausalBranchAtPath, | ||
|
@@ -13,6 +8,7 @@ module U.Codebase.Sqlite.Operations | |
saveBranchV3, | ||
loadCausalBranchByCausalHash, | ||
expectCausalBranchByCausalHash, | ||
expectBranchByCausalHashId, | ||
expectBranchByBranchHash, | ||
expectBranchByBranchHashId, | ||
expectNamespaceStatsByHash, | ||
|
@@ -100,9 +96,16 @@ module U.Codebase.Sqlite.Operations | |
fuzzySearchDefinitions, | ||
namesPerspectiveForRootAndPath, | ||
|
||
-- * Projects | ||
expectProjectAndBranchNames, | ||
expectProjectBranchHead, | ||
|
||
-- * reflog | ||
getReflog, | ||
appendReflog, | ||
getDeprecatedRootReflog, | ||
getProjectReflog, | ||
getProjectBranchReflog, | ||
getGlobalReflog, | ||
appendProjectReflog, | ||
|
||
-- * low-level stuff | ||
expectDbBranch, | ||
|
@@ -183,6 +186,9 @@ import U.Codebase.Sqlite.Patch.TermEdit qualified as S | |
import U.Codebase.Sqlite.Patch.TermEdit qualified as S.TermEdit | ||
import U.Codebase.Sqlite.Patch.TypeEdit qualified as S | ||
import U.Codebase.Sqlite.Patch.TypeEdit qualified as S.TypeEdit | ||
import U.Codebase.Sqlite.Project (Project (..)) | ||
import U.Codebase.Sqlite.ProjectBranch (ProjectBranch (..)) | ||
import U.Codebase.Sqlite.ProjectReflog qualified as ProjectReflog | ||
import U.Codebase.Sqlite.Queries qualified as Q | ||
import U.Codebase.Sqlite.Reference qualified as S | ||
import U.Codebase.Sqlite.Reference qualified as S.Reference | ||
|
@@ -200,6 +206,7 @@ import U.Codebase.TypeEdit qualified as C.TypeEdit | |
import U.Codebase.WatchKind (WatchKind) | ||
import U.Util.Base32Hex qualified as Base32Hex | ||
import U.Util.Serialization qualified as S | ||
import Unison.Core.Project (ProjectBranchName, ProjectName) | ||
import Unison.Hash qualified as H | ||
import Unison.Hash32 qualified as Hash32 | ||
import Unison.NameSegment (NameSegment) | ||
|
@@ -232,23 +239,10 @@ expectValueHashByCausalHashId = loadValueHashById <=< Q.expectCausalValueHashId | |
loadValueHashById :: Db.BranchHashId -> Transaction BranchHash | ||
loadValueHashById = fmap BranchHash . Q.expectHash . Db.unBranchHashId | ||
|
||
expectRootCausalHash :: Transaction CausalHash | ||
expectRootCausalHash = Q.expectCausalHash =<< Q.expectNamespaceRoot | ||
|
||
expectRootBranchHash :: Transaction BranchHash | ||
expectRootBranchHash = do | ||
rootCausalHashId <- Q.expectNamespaceRoot | ||
expectValueHashByCausalHashId rootCausalHashId | ||
|
||
loadRootCausalHash :: Transaction (Maybe CausalHash) | ||
loadRootCausalHash = | ||
runMaybeT $ | ||
lift . Q.expectCausalHash =<< MaybeT Q.loadNamespaceRoot | ||
|
||
-- | Load the causal hash at the given path from the provided root, if Nothing, use the | ||
-- codebase root. | ||
loadCausalHashAtPath :: Maybe CausalHash -> [NameSegment] -> Transaction (Maybe CausalHash) | ||
loadCausalHashAtPath mayRootCausalHash = | ||
loadCausalHashAtPath :: CausalHash -> [NameSegment] -> Transaction (Maybe CausalHash) | ||
loadCausalHashAtPath rootCausalHash = | ||
let go :: Db.CausalHashId -> [NameSegment] -> MaybeT Transaction CausalHash | ||
go hashId = \case | ||
[] -> lift (Q.expectCausalHash hashId) | ||
|
@@ -258,15 +252,13 @@ loadCausalHashAtPath mayRootCausalHash = | |
(_, hashId') <- MaybeT (pure (Map.lookup tid children)) | ||
go hashId' ts | ||
in \path -> do | ||
hashId <- case mayRootCausalHash of | ||
Nothing -> Q.expectNamespaceRoot | ||
Just rootCH -> Q.expectCausalHashIdByCausalHash rootCH | ||
hashId <- Q.expectCausalHashIdByCausalHash rootCausalHash | ||
runMaybeT (go hashId path) | ||
|
||
-- | Expect the causal hash at the given path from the provided root, if Nothing, use the | ||
-- codebase root. | ||
expectCausalHashAtPath :: Maybe CausalHash -> [NameSegment] -> Transaction CausalHash | ||
expectCausalHashAtPath mayRootCausalHash = | ||
expectCausalHashAtPath :: CausalHash -> [NameSegment] -> Transaction CausalHash | ||
expectCausalHashAtPath rootCausalHash = | ||
let go :: Db.CausalHashId -> [NameSegment] -> Transaction CausalHash | ||
go hashId = \case | ||
[] -> Q.expectCausalHash hashId | ||
|
@@ -276,23 +268,21 @@ expectCausalHashAtPath mayRootCausalHash = | |
let (_, hashId') = children Map.! tid | ||
go hashId' ts | ||
in \path -> do | ||
hashId <- case mayRootCausalHash of | ||
Nothing -> Q.expectNamespaceRoot | ||
Just rootCH -> Q.expectCausalHashIdByCausalHash rootCH | ||
hashId <- Q.expectCausalHashIdByCausalHash rootCausalHash | ||
go hashId path | ||
|
||
loadCausalBranchAtPath :: | ||
Maybe CausalHash -> | ||
CausalHash -> | ||
[NameSegment] -> | ||
Transaction (Maybe (C.Branch.CausalBranch Transaction)) | ||
loadCausalBranchAtPath maybeRootCausalHash path = | ||
loadCausalHashAtPath maybeRootCausalHash path >>= \case | ||
loadCausalBranchAtPath rootCausalHash path = | ||
loadCausalHashAtPath rootCausalHash path >>= \case | ||
Nothing -> pure Nothing | ||
Just causalHash -> Just <$> expectCausalBranchByCausalHash causalHash | ||
|
||
loadBranchAtPath :: Maybe CausalHash -> [NameSegment] -> Transaction (Maybe (C.Branch.Branch Transaction)) | ||
loadBranchAtPath maybeRootCausalHash path = | ||
loadCausalBranchAtPath maybeRootCausalHash path >>= \case | ||
loadBranchAtPath :: CausalHash -> [NameSegment] -> Transaction (Maybe (C.Branch.Branch Transaction)) | ||
loadBranchAtPath rootCausalHash path = | ||
loadCausalBranchAtPath rootCausalHash path >>= \case | ||
Nothing -> pure Nothing | ||
Just causal -> Just <$> C.Causal.value causal | ||
|
||
|
@@ -613,16 +603,6 @@ s2cBranch (S.Branch.Full.Branch tms tps patches children) = | |
boId <- Q.expectBranchObjectIdByCausalHashId chId | ||
expectBranch boId | ||
|
||
saveRootBranch :: | ||
HashHandle -> | ||
C.Branch.CausalBranch Transaction -> | ||
Transaction (Db.BranchObjectId, Db.CausalHashId) | ||
saveRootBranch hh c = do | ||
when debug $ traceM $ "Operations.saveRootBranch " ++ show (C.causalHash c) | ||
(boId, chId) <- saveBranch hh c | ||
Q.setNamespaceRoot chId | ||
pure (boId, chId) | ||
|
||
-- saveBranch is kind of a "deep save causal" | ||
|
||
-- we want a "shallow save causal" that could take a | ||
|
@@ -749,9 +729,6 @@ saveCausalObject hh (C.Causal.Causal hc he parents _) = do | |
Q.saveCausal hh chId bhId parentCausalHashIds | ||
pure (chId, bhId) | ||
|
||
expectRootCausal :: Transaction (C.Branch.CausalBranch Transaction) | ||
expectRootCausal = Q.expectNamespaceRoot >>= expectCausalBranchByCausalHashId | ||
|
||
loadCausalBranchByCausalHash :: CausalHash -> Transaction (Maybe (C.Branch.CausalBranch Transaction)) | ||
loadCausalBranchByCausalHash hc = do | ||
Q.loadCausalHashIdByCausalHash hc >>= \case | ||
|
@@ -1510,15 +1487,43 @@ namespaceStatsForDbBranch = \case | |
expectNamespaceStatsByHashId bhId | ||
|
||
-- | Gets the specified number of reflog entries in chronological order, most recent first. | ||
getReflog :: Int -> Transaction [Reflog.Entry CausalHash Text] | ||
getReflog numEntries = do | ||
entries <- Q.getReflog numEntries | ||
getDeprecatedRootReflog :: Int -> Transaction [Reflog.Entry CausalHash Text] | ||
getDeprecatedRootReflog numEntries = do | ||
entries <- Q.getDeprecatedRootReflog numEntries | ||
traverse (bitraverse Q.expectCausalHash pure) entries | ||
|
||
appendReflog :: Reflog.Entry CausalHash Text -> Transaction () | ||
appendReflog entry = do | ||
dbEntry <- (bitraverse Q.saveCausalHash pure) entry | ||
Q.appendReflog dbEntry | ||
-- | Gets the specified number of reflog entries for the given project in chronological order, most recent first. | ||
getProjectReflog :: Int -> Db.ProjectId -> Transaction [ProjectReflog.Entry Project ProjectBranch CausalHash] | ||
getProjectReflog numEntries projectId = do | ||
entries <- Q.getProjectReflog numEntries projectId | ||
traverse hydrateProjectReflogEntry entries | ||
|
||
-- | Gets the specified number of reflog entries for the specified ProjectBranch in chronological order, most recent first. | ||
getProjectBranchReflog :: Int -> Db.ProjectBranchId -> Transaction [ProjectReflog.Entry Project ProjectBranch CausalHash] | ||
getProjectBranchReflog numEntries projectBranchId = do | ||
entries <- Q.getProjectBranchReflog numEntries projectBranchId | ||
traverse hydrateProjectReflogEntry entries | ||
|
||
-- | Gets the specified number of reflog entries in chronological order, most recent first. | ||
getGlobalReflog :: Int -> Transaction [ProjectReflog.Entry Project ProjectBranch CausalHash] | ||
getGlobalReflog numEntries = do | ||
entries <- Q.getGlobalReflog numEntries | ||
traverse hydrateProjectReflogEntry entries | ||
|
||
hydrateProjectReflogEntry :: ProjectReflog.Entry Db.ProjectId Db.ProjectBranchId Db.CausalHashId -> Transaction (ProjectReflog.Entry Project ProjectBranch CausalHash) | ||
hydrateProjectReflogEntry entry = do | ||
traverse Q.expectCausalHash entry | ||
>>= ProjectReflog.projectAndBranch_ | ||
%%~ ( \(projId, branchId) -> do | ||
proj <- Q.expectProject projId | ||
branch <- Q.expectProjectBranch projId branchId | ||
pure (proj, branch) | ||
) | ||
|
||
appendProjectReflog :: ProjectReflog.Entry Db.ProjectId Db.ProjectBranchId CausalHash -> Transaction () | ||
appendProjectReflog entry = do | ||
dbEntry <- traverse Q.saveCausalHash entry | ||
Q.appendProjectBranchReflog dbEntry | ||
|
||
-- | Delete any name lookup that's not in the provided list. | ||
-- | ||
|
@@ -1584,3 +1589,14 @@ stripPrefixFromNamedRef (PathSegments prefix) namedRef = | |
Nothing -> reversedName | ||
Just strippedReversedPath -> S.ReversedName (name NonEmpty.:| strippedReversedPath) | ||
in namedRef {S.reversedSegments = newReversedName} | ||
|
||
expectProjectAndBranchNames :: Db.ProjectId -> Db.ProjectBranchId -> Transaction (ProjectName, ProjectBranchName) | ||
expectProjectAndBranchNames projectId projectBranchId = do | ||
Project {name = pName} <- Q.expectProject projectId | ||
ProjectBranch {name = bName} <- Q.expectProjectBranch projectId projectBranchId | ||
pure (pName, bName) | ||
|
||
expectProjectBranchHead :: Db.ProjectId -> Db.ProjectBranchId -> Transaction CausalHash | ||
expectProjectBranchHead projId projectBranchId = do | ||
chId <- Q.expectProjectBranchHead projId projectBranchId | ||
Q.expectCausalHash chId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
codebase2/codebase-sqlite/U/Codebase/Sqlite/ProjectReflog.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# LANGUAGE ViewPatterns #-} | ||
|
||
module U.Codebase.Sqlite.ProjectReflog | ||
( Entry (..), | ||
project_, | ||
branch_, | ||
projectAndBranch_, | ||
) | ||
where | ||
|
||
import Control.Lens | ||
import Data.Text (Text) | ||
import Data.Time (UTCTime) | ||
import U.Codebase.Sqlite.DbId (CausalHashId, ProjectBranchId, ProjectId) | ||
import Unison.Sqlite (FromRow (..), ToRow (..), field) | ||
|
||
data Entry project branch causal = Entry | ||
{ project :: project, | ||
branch :: branch, | ||
time :: UTCTime, | ||
fromRootCausalHash :: Maybe causal, | ||
toRootCausalHash :: causal, | ||
reason :: Text | ||
} | ||
deriving stock (Eq, Show, Functor, Foldable, Traversable) | ||
|
||
project_ :: Lens (Entry project branch causal) (Entry project' branch causal) project project' | ||
project_ = lens project (\e p -> e {project = p}) | ||
|
||
branch_ :: Lens (Entry project branch causal) (Entry project branch' causal) branch branch' | ||
branch_ = lens branch (\e b -> e {branch = b}) | ||
|
||
-- | Both Project and Branch Ids are required to load a branch, so this is often more useful. | ||
projectAndBranch_ :: Lens (Entry project branch causal) (Entry project' branch' causal) (project, branch) (project', branch') | ||
projectAndBranch_ = lens (\Entry {..} -> (project, branch)) (\e (project, branch) -> e {project = project, branch = branch}) | ||
|
||
instance ToRow (Entry ProjectId ProjectBranchId CausalHashId) where | ||
toRow (Entry proj branch time fromRootCausalHash toRootCausalHash reason) = | ||
toRow (proj, branch, time, fromRootCausalHash, toRootCausalHash, reason) | ||
|
||
instance FromRow (Entry ProjectId ProjectBranchId CausalHashId) where | ||
fromRow = do | ||
project <- field | ||
branch <- field | ||
time <- field | ||
fromRootCausalHash <- field | ||
toRootCausalHash <- field | ||
reason <- field | ||
pure $ Entry {..} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arya and I believe this was for some ancient transcript stuff that doesn't exist anymore, but it was also preventing changes to one of our transcripts that started with
transcript-
so I removed it.