Merge branch 'trunk' into 24-08-01-merge-api

This commit is contained in:
Arya Irani 2024-08-13 10:17:23 -04:00 committed by Arya Irani
commit ed555a3ea1
7 changed files with 2943 additions and 11 deletions

View File

@ -3500,7 +3500,11 @@ getProjectReflog numEntries projectId =
SELECT project_id, project_branch_id, time, from_root_causal_id, to_root_causal_id, reason
FROM project_branch_reflog
WHERE project_id = :projectId
ORDER BY time DESC
ORDER BY
time DESC,
-- Strictly for breaking ties in transcripts with the same time,
-- this will break ties in the correct order, sorting later inserted rows first.
ROWID DESC
LIMIT :numEntries
|]
@ -3512,7 +3516,11 @@ getProjectBranchReflog numEntries projectBranchId =
SELECT project_id, project_branch_id, time, from_root_causal_id, to_root_causal_id, reason
FROM project_branch_reflog
WHERE project_branch_id = :projectBranchId
ORDER BY time DESC
ORDER BY
time DESC,
-- Strictly for breaking ties in transcripts with the same time,
-- this will break ties in the correct order, sorting later inserted rows first.
ROWID DESC
LIMIT :numEntries
|]
@ -3523,7 +3531,11 @@ getGlobalReflog numEntries =
[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
ORDER BY
time DESC,
-- Strictly for breaking ties in transcripts with the same time,
-- this will break ties in the correct order, sorting later inserted rows first.
ROWID DESC
LIMIT :numEntries
|]

View File

@ -7,7 +7,7 @@ module Unison.Codebase.Editor.HandleInput.Update2
)
where
import Control.Lens (mapped)
import Control.Lens (mapped, (.=))
import Control.Monad.Reader.Class (ask)
import Data.Bifoldable (bifoldMap)
import Data.Foldable qualified as Foldable
@ -167,6 +167,7 @@ handleUpdate2 = do
(\typeName -> Right (Map.lookup typeName declNameLookup.declToConstructors))
secondTuf
Cli.stepAt "update" (path, Branch.batchUpdates branchUpdates)
#latestTypecheckedFile .= Nothing
Cli.respond Output.Success

View File

@ -59,5 +59,17 @@ diffSyntaxText (AnnotatedText fromST) (AnnotatedText toST) =
detectSpecialCase fromSegment toSegment
| fromSegment == toSegment = Left fromSegment
| AT.annotation fromSegment == AT.annotation toSegment = Right (SegmentChange (AT.segment fromSegment, AT.segment toSegment) (AT.annotation fromSegment))
| AT.segment fromSegment == AT.segment toSegment = Right (AnnotationChange (AT.segment fromSegment) (AT.annotation fromSegment, AT.annotation toSegment))
-- We only emit an annotation change if it's a change in just the hash of the element (optionally the KIND of hash reference can change too).
| AT.segment fromSegment == AT.segment toSegment,
Just _fromHash <- AT.annotation fromSegment >>= elementHash,
Just _toHash <- AT.annotation toSegment >>= elementHash =
Right (AnnotationChange (AT.segment fromSegment) (AT.annotation fromSegment, AT.annotation toSegment))
| otherwise = error "diffSyntaxText: found Syntax Elements in 'both' which have nothing in common."
where
elementHash :: Syntax.Element -> Maybe Syntax.UnisonHash
elementHash = \case
Syntax.TypeReference hash -> Just hash
Syntax.TermReference hash -> Just hash
Syntax.DataConstructorReference hash -> Just hash
Syntax.AbilityConstructorReference hash -> Just hash
_ -> Nothing

View File

@ -1,5 +1,7 @@
```ucm
diffs/main> builtins.merge
diffs/main> builtins.mergeio lib.builtins
diffs/main> alias.term lib.builtins.Nat.gt lib.builtins.Nat.>
diffs/main> alias.term lib.builtins.Nat.drop lib.builtins.Nat.-
```
```unison
@ -8,6 +10,20 @@ term =
1 + 1
type Type = Type Nat
ability Stream a where
emit : a -> ()
take n s =
use Nat > -
h n = cases
{ emit a -> k } -> if n > 0
then
emit a
handle k() with h (n - 1)
else None
{ r } -> Some r
handle s() with h n
```
```ucm
@ -21,6 +37,22 @@ term =
1 + 2
type Type a = Type a Text
ability Stream a where
emit : a -> ()
take n s =
use Nat > -
h n = cases
{ emit a -> k } ->
emit a
if n > 0
then handle k() with h (n - 1)
else None
{ r } -> Some r
if n > 0
then handle s () with h (n - 1)
else None
```
```ucm
@ -33,6 +65,13 @@ Diff terms
GET /api/projects/diffs/diff/terms?oldBranchRef=main&newBranchRef=new&oldTerm=term&newTerm=term
```
More complex diff
```api
GET /api/projects/diffs/diff/terms?oldBranchRef=main&newBranchRef=new&oldTerm=take&newTerm=take
```
Diff types
```api

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
```ucm
scratch/main> builtins.merge lib.builtins
```
```unison:hide
a = do b
b = "Hello, " ++ c ++ "!"
c = "World"
```
```ucm
scratch/main> add
scratch/main> run a
```
```unison:hide
a = do b
c = "Unison"
```
```ucm
scratch/main> update
scratch/main> run a
```
The result should be "Hello, Unison!".

View File

@ -0,0 +1,50 @@
``` ucm
scratch/main> builtins.merge lib.builtins
Done.
```
``` unison
a = do b
b = "Hello, " ++ c ++ "!"
c = "World"
```
``` ucm
scratch/main> add
⍟ I've added these definitions:
a : 'Text
b : Text
c : Text
scratch/main> run a
"Hello, World!"
```
``` unison
a = do b
c = "Unison"
```
``` ucm
scratch/main> update
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
scratch/main> run a
"Hello, Unison!"
```
The result should be "Hello, Unison\!".