mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
Swap branch-relative-paths back to relative
This commit is contained in:
parent
40458056a8
commit
987cd61976
@ -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
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
||||
```
|
||||
|
@ -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
|
||||
```
|
||||
|
@ -145,7 +145,7 @@ foo/main> update
|
||||
|
||||
Done.
|
||||
|
||||
foo/empty> reset /main:.
|
||||
foo/empty> reset /main:
|
||||
|
||||
Done.
|
||||
|
||||
|
@ -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
|
||||
```
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user