diff --git a/parser-typechecker/src/Unison/Codebase/ProjectPath.hs b/parser-typechecker/src/Unison/Codebase/ProjectPath.hs index ffb7b0850..2714c44e4 100644 --- a/parser-typechecker/src/Unison/Codebase/ProjectPath.hs +++ b/parser-typechecker/src/Unison/Codebase/ProjectPath.hs @@ -54,12 +54,12 @@ instance From ProjectPath Text where from = from . toNames instance From ProjectPathNames Text where - from (ProjectPath proj branch path) = - into @Text (ProjectAndBranch proj branch) <> ":" <> Path.absToText path + from (ProjectPath proj branch (Path.Absolute path)) = + into @Text (ProjectAndBranch proj branch) <> ":" <> Path.toText path instance From (ProjectPathG () ProjectBranchName) Text where - from (ProjectPath () branch path) = - "/" <> into @Text branch <> ":" <> Path.absToText path + from (ProjectPath () branch (Path.Absolute path)) = + "/" <> into @Text branch <> ":" <> Path.toText path type ProjectPath = ProjectPathG Project ProjectBranch diff --git a/unison-cli/src/Unison/CommandLine/BranchRelativePath.hs b/unison-cli/src/Unison/CommandLine/BranchRelativePath.hs index 116dbb60e..cc49baa3c 100644 --- a/unison-cli/src/Unison/CommandLine/BranchRelativePath.hs +++ b/unison-cli/src/Unison/CommandLine/BranchRelativePath.hs @@ -166,13 +166,13 @@ incrementalBranchRelativePathParser = Megaparsec.Parsec Void Text IncrementalBranchRelativePath startingAtColon projStuff = do _ <- Megaparsec.char ':' - p <- optionalEof absPath + p <- optionalEof brPath pure (IncompletePath projStuff p) pathRelativeToCurrentBranch :: Megaparsec.Parsec Void Text IncrementalBranchRelativePath pathRelativeToCurrentBranch = do _ <- Megaparsec.char ':' - p <- absPath + p <- brPath pure (PathRelativeToCurrentBranch p) optionalEof :: Megaparsec.Parsec Void Text a -> Megaparsec.Parsec Void Text (Maybe a) @@ -183,12 +183,13 @@ incrementalBranchRelativePathParser = branchNameParser = Project.projectBranchNameParser False - absPath :: Megaparsec.Parsec Void Text Path.Absolute - absPath = do + brPath :: Megaparsec.Parsec Void Text Path.Absolute + brPath = do offset <- Megaparsec.getOffset path' >>= \(Path.Path' inner) -> case inner of - Left p -> pure p - Right _ -> failureAt offset "Expected an absolute path but found a relative path. Try adding a leading '.' to your path" + Left _ -> failureAt offset "Branch qualified paths don't require a leading '.'" + -- Branch relative paths are written as relative paths, but are always absolute to the branch root + Right (Path.Relative x) -> pure $ Path.Absolute x path' = Megaparsec.try do offset <- Megaparsec.getOffset pathStr <- Megaparsec.takeRest @@ -235,6 +236,6 @@ branchRelativePathParser = toText :: BranchRelativePath -> Text toText = \case - BranchPathInCurrentProject pbName absPath -> ProjectPath () pbName absPath & into @Text - QualifiedBranchPath projName pbName absPath -> ProjectPath projName pbName absPath & into @Text + BranchPathInCurrentProject pbName path -> ProjectPath () pbName path & into @Text + QualifiedBranchPath projName pbName path -> ProjectPath projName pbName path & into @Text UnqualifiedPath path' -> Path.toText' path' diff --git a/unison-src/transcripts-round-trip/main.md b/unison-src/transcripts-round-trip/main.md index 7caf8f80e..a7d7b01f3 100644 --- a/unison-src/transcripts-round-trip/main.md +++ b/unison-src/transcripts-round-trip/main.md @@ -41,7 +41,7 @@ scratch/a2> delete.namespace.force lib.builtins This diff should be empty if the two namespaces are equivalent. If it's nonempty, the diff will show us the hashes that differ. ```ucm:error -scratch/main> diff.namespace /a1:. /a2:. +scratch/main> diff.namespace /a1: /a2: ``` Now check that definitions in 'reparses.u' at least parse on round trip: @@ -77,7 +77,7 @@ scratch/a3_new> delete.namespace.force lib.builtins These are currently all expected to have different hashes on round trip. ```ucm -scratch/main> diff.namespace /a3_new:. /a3:. +scratch/main> diff.namespace /a3_new: /a3: ``` ## Other regression tests not covered by above diff --git a/unison-src/transcripts-round-trip/main.output.md b/unison-src/transcripts-round-trip/main.output.md index 18b455b30..def526633 100644 --- a/unison-src/transcripts-round-trip/main.output.md +++ b/unison-src/transcripts-round-trip/main.output.md @@ -771,7 +771,7 @@ a |> f = f a This diff should be empty if the two namespaces are equivalent. If it's nonempty, the diff will show us the hashes that differ. ``` ucm -scratch/main> diff.namespace /a1:. /a2:. +scratch/main> diff.namespace /a1: /a2: The namespaces are identical. @@ -820,7 +820,7 @@ sloppyDocEval = These are currently all expected to have different hashes on round trip. ``` ucm -scratch/main> diff.namespace /a3_new:. /a3:. +scratch/main> diff.namespace /a3_new: /a3: Updates: diff --git a/unison-src/transcripts/branch-relative-path.md b/unison-src/transcripts/branch-relative-path.md index 49bd4863b..77de24703 100644 --- a/unison-src/transcripts/branch-relative-path.md +++ b/unison-src/transcripts/branch-relative-path.md @@ -14,11 +14,11 @@ donk.bonk = 1 ```ucm p1/main> add -p1/main> fork p0/main:. zzz +p1/main> fork p0/main: zzz p1/main> find zzz -p1/main> fork p0/main:.foo yyy +p1/main> fork p0/main:foo yyy p1/main> find yyy -p0/main> fork p1/main:. p0/main:.p1 +p0/main> fork p1/main: p0/main:p1 p0/main> ls p1 p0/main> ls p1.zzz p0/main> ls p1.yyy diff --git a/unison-src/transcripts/branch-relative-path.output.md b/unison-src/transcripts/branch-relative-path.output.md index 35592794a..e9e33b5ad 100644 --- a/unison-src/transcripts/branch-relative-path.output.md +++ b/unison-src/transcripts/branch-relative-path.output.md @@ -55,7 +55,7 @@ p1/main> add bonk : ##Nat donk.bonk : ##Nat -p1/main> fork p0/main:. zzz +p1/main> fork p0/main: zzz Done. @@ -65,7 +65,7 @@ p1/main> find zzz 2. zzz.foo.bar : ##Nat -p1/main> fork p0/main:.foo yyy +p1/main> fork p0/main:foo yyy Done. @@ -74,7 +74,7 @@ p1/main> find yyy 1. yyy.bar : ##Nat -p0/main> fork p1/main:. p0/main:.p1 +p0/main> fork p1/main: p0/main:p1 Done. diff --git a/unison-src/transcripts/reflog.output.md b/unison-src/transcripts/reflog.output.md index d0c001dcf..9fbff9031 100644 --- a/unison-src/transcripts/reflog.output.md +++ b/unison-src/transcripts/reflog.output.md @@ -84,7 +84,7 @@ scratch/main> reflog Branch Hash Description 1. scratch/main #6mdl5gruh5 add 2. scratch/main #3rqf1hbev7 add - 3. scratch/main #ms9lggs2rg builtins.merge scratch/main:.lib.builtins + 3. scratch/main #ms9lggs2rg builtins.merge scratch/main:lib.builtins 4. scratch/main #sg60bvjo91 Project Created ``` @@ -101,11 +101,11 @@ scratch/main> project.reflog history. Branch Hash Description - 1. scratch/other #148flqs4b1 alias.term scratch/other:..y scratch/other:.z + 1. scratch/other #148flqs4b1 alias.term scratch/other:.y scratch/other:z 2. scratch/other #6mdl5gruh5 Branch created from scratch/main 3. scratch/main #6mdl5gruh5 add 4. scratch/main #3rqf1hbev7 add - 5. scratch/main #ms9lggs2rg builtins.merge scratch/main:.lib.builtins + 5. scratch/main #ms9lggs2rg builtins.merge scratch/main:lib.builtins 6. scratch/main #sg60bvjo91 Project Created ``` @@ -122,14 +122,14 @@ scratch/main> reflog.global history. Branch Hash Description - 1. newproject/main #2rjhs2vq43 alias.term newproject/main:.lib.builtins.Nat newproject/main... - 2. newproject/main #ms9lggs2rg builtins.merge newproject/main:.lib.builtins + 1. newproject/main #2rjhs2vq43 alias.term newproject/main:lib.builtins.Nat newproject/main:... + 2. newproject/main #ms9lggs2rg builtins.merge newproject/main:lib.builtins 3. newproject/main #sg60bvjo91 Branch Created - 4. scratch/other #148flqs4b1 alias.term scratch/other:..y scratch/other:.z + 4. scratch/other #148flqs4b1 alias.term scratch/other:.y scratch/other:z 5. scratch/other #6mdl5gruh5 Branch created from scratch/main 6. scratch/main #6mdl5gruh5 add 7. scratch/main #3rqf1hbev7 add - 8. scratch/main #ms9lggs2rg builtins.merge scratch/main:.lib.builtins + 8. scratch/main #ms9lggs2rg builtins.merge scratch/main:lib.builtins 9. scratch/main #sg60bvjo91 Project Created ``` diff --git a/unison-src/transcripts/reset.md b/unison-src/transcripts/reset.md index 2cd19597d..e430ef290 100644 --- a/unison-src/transcripts/reset.md +++ b/unison-src/transcripts/reset.md @@ -46,7 +46,7 @@ a = 5 ```ucm foo/main> update -foo/empty> reset /main:. +foo/empty> reset /main: foo/empty> view a foo/empty> history ``` diff --git a/unison-src/transcripts/reset.output.md b/unison-src/transcripts/reset.output.md index 26c2ad4e2..7bcdacc4a 100644 --- a/unison-src/transcripts/reset.output.md +++ b/unison-src/transcripts/reset.output.md @@ -145,7 +145,7 @@ foo/main> update Done. -foo/empty> reset /main:. +foo/empty> reset /main: Done. diff --git a/unison-src/transcripts/view.md b/unison-src/transcripts/view.md index f281cf3ec..5c2b0e8c5 100644 --- a/unison-src/transcripts/view.md +++ b/unison-src/transcripts/view.md @@ -27,5 +27,5 @@ TODO: swap this back to a 'ucm' block when view.global is re-implemented -- view.global should search globally and be absolutely qualified scratch/other> view.global thing -- Should support branch relative paths -scratch/other> view /main:.a.thing +scratch/other> view /main:a.thing ``` diff --git a/unison-src/transcripts/view.output.md b/unison-src/transcripts/view.output.md index 6a8613378..a4698d9d0 100644 --- a/unison-src/transcripts/view.output.md +++ b/unison-src/transcripts/view.output.md @@ -27,5 +27,5 @@ TODO: swap this back to a 'ucm' block when view.global is re-implemented -- view.global should search globally and be absolutely qualified scratch/other> view.global thing -- Should support branch relative paths - scratch/other> view /main:.a.thing + scratch/other> view /main:a.thing