diff --git a/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs b/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs index f77bfbbf4..927021ece 100644 --- a/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs +++ b/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs @@ -3498,8 +3498,8 @@ getProjectReflog numEntries projectId = [sql| SELECT project_id, project_branch_id, time, from_root_causal_id, to_root_causal_id, reason FROM project_branch_reflog - ORDER BY time DESC WHERE project_id = :projectId + ORDER BY time DESC LIMIT :numEntries |] @@ -3510,8 +3510,8 @@ getProjectBranchReflog numEntries projectBranchId = [sql| SELECT project_id, project_branch_id, time, from_root_causal_id, to_root_causal_id, reason FROM project_branch_reflog - ORDER BY time DESC WHERE project_branch_id = :projectBranchId + ORDER BY time DESC LIMIT :numEntries |] diff --git a/codebase2/codebase-sqlite/sql/013-add-project-branch-reflog-table.sql b/codebase2/codebase-sqlite/sql/013-add-project-branch-reflog-table.sql index 589ed1812..514205103 100644 --- a/codebase2/codebase-sqlite/sql/013-add-project-branch-reflog-table.sql +++ b/codebase2/codebase-sqlite/sql/013-add-project-branch-reflog-table.sql @@ -1,3 +1,4 @@ +-- A reflog which is tied to the project/branch CREATE TABLE project_branch_reflog ( project_id INTEGER NOT NULL, project_branch_id INTEGER NOT NULL, @@ -24,3 +25,8 @@ CREATE INDEX project_reflog_by_time ON project_branch_reflog ( project_id, time DESC ); +CREATE INDEX global_reflog_by_time ON project_branch_reflog ( + time DESC +); + + diff --git a/parser-typechecker/src/Unison/Codebase/ShortCausalHash.hs b/parser-typechecker/src/Unison/Codebase/ShortCausalHash.hs index c23babd33..2872ec53d 100644 --- a/parser-typechecker/src/Unison/Codebase/ShortCausalHash.hs +++ b/parser-typechecker/src/Unison/Codebase/ShortCausalHash.hs @@ -48,3 +48,6 @@ fromText _ = Nothing instance Show ShortCausalHash where show (ShortCausalHash h) = '#' : Text.unpack h + +instance From ShortCausalHash Text where + from = toText diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs index 4c3731aba..9af1e4860 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs @@ -1071,11 +1071,11 @@ inputDescription input = VersionI -> wat where hp' :: Either SCH.ShortCausalHash Path' -> Cli Text - hp' = either (pure . Text.pack . show) p' + hp' = either (pure . into @Text) p' p :: Path -> Cli Text - p = fmap tShow . Cli.resolvePath + p = fmap (into @Text) . Cli.resolvePath p' :: Path' -> Cli Text - p' = fmap tShow . Cli.resolvePath' + p' = fmap (into @Text) . Cli.resolvePath' brp :: BranchRelativePath -> Cli Text brp = fmap (into @Text) . ProjectUtils.resolveBranchRelativePath ops :: Maybe Path.Split -> Cli Text diff --git a/unison-cli/src/Unison/CommandLine/InputPatterns.hs b/unison-cli/src/Unison/CommandLine/InputPatterns.hs index 21519482a..fc8714330 100644 --- a/unison-cli/src/Unison/CommandLine/InputPatterns.hs +++ b/unison-cli/src/Unison/CommandLine/InputPatterns.hs @@ -3481,7 +3481,8 @@ validInputs = viewGlobal, deprecatedViewRootReflog, branchReflog, - projectReflog + projectReflog, + globalReflog ] -- | A map of all command patterns by pattern name or alias. diff --git a/unison-src/transcripts/reflog.md b/unison-src/transcripts/reflog.md index 0c1a33fba..0bbb4f57d 100644 --- a/unison-src/transcripts/reflog.md +++ b/unison-src/transcripts/reflog.md @@ -2,8 +2,7 @@ scratch/main> builtins.merge lib.builtins ``` -First we make two changes to the codebase, so that there's more than one line -for the `reflog` command to display: +First we make some changes to the codebase so there's data in the reflog. ```unison x = 1 @@ -16,16 +15,27 @@ y = 2 ``` ```ucm scratch/main> add -scratch/main> view y +scratch/main> branch /other +scratch/other> alias.term y z +newproject/main> builtins.merge lib.builtins +newproject/main> alias.type lib.builtins.Nat MyNat ``` + +Should see reflog entries from the current branch + ```ucm scratch/main> reflog ``` -If we `reset-root` to its previous value, `y` disappears. +Should see reflog entries from the current project + ```ucm -scratch/main> reset-root 2 +scratch/main> project.reflog ``` -```ucm:error -scratch/main> view y + + +Should see reflog entries from all projects + +```ucm +scratch/main> reflog.global ``` diff --git a/unison-src/transcripts/reflog.output.md b/unison-src/transcripts/reflog.output.md index 54ea82800..22e359c0f 100644 --- a/unison-src/transcripts/reflog.output.md +++ b/unison-src/transcripts/reflog.output.md @@ -1,5 +1,4 @@ -First we make two changes to the codebase, so that there's more than one line -for the `reflog` command to display: +First we make some changes to the codebase so there's data in the reflog. ```unison x = 1 @@ -50,37 +49,87 @@ scratch/main> add y : Nat -scratch/main> view y +scratch/main> branch /other - y : Nat - y = 2 + Done. I've created the other branch based off of main. + + Tip: To merge your work back into the main branch, first + `switch /main` then `merge /other`. + +scratch/other> alias.term y z + + Done. + +newproject/main> builtins.merge lib.builtins + + Done. + +newproject/main> alias.type lib.builtins.Nat MyNat + + Done. ``` +Should see reflog entries from the current branch + ```ucm scratch/main> reflog - ⚠️ + Below is a record of recent changes, you can use + `reset #abcdef` to reset the current branch to a previous + state. - The reflog is empty + Tip: Use `diff.namespace 1 7` to compare between points in + history. + + Branch When Hash Description + 1. scratch/main now #6mdl5gruh5 add + 2. scratch/main now #3rqf1hbev7 add + 3. scratch/main now #ms9lggs2rg builtins.merge scratch/main:.lib.builtins + 4. scratch/main now #sg60bvjo91 Project Created ``` -If we `reset-root` to its previous value, `y` disappears. +Should see reflog entries from the current project + ```ucm -scratch/main> reset-root 2 +scratch/main> project.reflog + + Below is a record of recent changes, you can use + `reset #abcdef` to reset the current branch to a previous + state. + + Tip: Use `diff.namespace 1 7` to compare between points in + history. + + Branch When Hash Description + 1. scratch/other now #148flqs4b1 alias.term scratch/other:..y scratch/other:.z + 2. scratch/other now #6mdl5gruh5 Branch created from scratch/main + 3. scratch/main now #6mdl5gruh5 add + 4. scratch/main now #3rqf1hbev7 add + 5. scratch/main now #ms9lggs2rg builtins.merge scratch/main:.lib.builtins + 6. scratch/main now #sg60bvjo91 Project Created ``` +Should see reflog entries from all projects + ```ucm -scratch/main> view y +scratch/main> reflog.global - y : Nat - y = 2 + Below is a record of recent changes, you can use + `reset #abcdef` to reset the current branch to a previous + state. + + Tip: Use `diff.namespace 1 7` to compare between points in + history. + + Branch When Hash Description + 1. newproject/main now #2rjhs2vq43 alias.term newproject/main:.lib.builtins.Nat newproject/main... + 2. newproject/main now #ms9lggs2rg builtins.merge newproject/main:.lib.builtins + 3. newproject/main now #sg60bvjo91 Branch Created + 4. scratch/other now #148flqs4b1 alias.term scratch/other:..y scratch/other:.z + 5. scratch/other now #6mdl5gruh5 Branch created from scratch/main + 6. scratch/main now #6mdl5gruh5 add + 7. scratch/main now #3rqf1hbev7 add + 8. scratch/main now #ms9lggs2rg builtins.merge scratch/main:.lib.builtins + 9. scratch/main now #sg60bvjo91 Project Created ``` - -``` - - - -🛑 - -The transcript was expecting an error in the stanza above, but did not encounter one.