Skip to content

Commit 3cb4c4d

Browse files
update merge.md with new test cases
1 parent 9d6bc6d commit 3cb4c4d

File tree

3 files changed

+476
-10
lines changed

3 files changed

+476
-10
lines changed

unison-cli/src/Unison/Cli/UniqueTypeGuidLookup.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ loadUniqueTypeGuid pp name0 = do
5151
-- a new GUID because it's not clear whether alice's or bob's should be preferred.
5252
(Just aliceGuid, Just bobGuid) -> do
5353
case (aliceMaybeBranchId, bobMaybeBranchId) of
54-
(Just aliceBranchId, Just bobBranchId) ->
55-
Queries.loadProjectBranchParent pp.project.projectId aliceBranchId >>= \case
56-
Just aliceParentBranchId ->
57-
if aliceParentBranchId == bobBranchId
58-
then pure (Just bobGuid)
59-
else
60-
Queries.loadProjectBranchParent pp.project.projectId bobBranchId <&> \case
61-
Just bobParentBranchId | bobParentBranchId == aliceBranchId -> Just aliceGuid
62-
_ -> Nothing
63-
Nothing -> pure Nothing
54+
(Just aliceBranchId, Just bobBranchId) -> do
55+
aliceParentBranchId <- Queries.loadProjectBranchParent pp.project.projectId aliceBranchId
56+
if aliceParentBranchId == Just bobBranchId
57+
then pure (Just bobGuid)
58+
else do
59+
bobParentBranchId <- Queries.loadProjectBranchParent pp.project.projectId bobBranchId
60+
pure
61+
if bobParentBranchId == Just aliceBranchId
62+
then Just aliceGuid
63+
else Nothing
6464
_ -> pure Nothing
6565
Just guid -> pure (Just guid)

unison-src/transcripts/merge.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,105 @@ scratch/alice> names Bar
17481748
scratch/main> project.delete scratch
17491749
```
17501750

1751+
### Unique type GUID reuse – parent branch
1752+
1753+
When on a merge branch, if the parser has to pick between two different GUIDs, and the two merge parents themselves have
1754+
a branch parent-child relationship, it will prefer the parent's GUID. If they don't the parser will make a new GUID.
1755+
1756+
``` ucm :hide
1757+
scratch/main> builtins.mergeio lib.builtins
1758+
```
1759+
1760+
``` unison
1761+
type Foo = Bar
1762+
```
1763+
1764+
``` ucm
1765+
scratch/main> branch topic
1766+
scratch/main> branch topic2
1767+
scratch/main> add
1768+
scratch/main> switch /topic
1769+
```
1770+
1771+
``` unison
1772+
type Foo = Bar
1773+
```
1774+
1775+
``` ucm
1776+
scratch/topic> add
1777+
scratch/topic> switch /topic2
1778+
```
1779+
1780+
``` unison
1781+
type Foo = Bar
1782+
```
1783+
1784+
``` ucm
1785+
scratch/topic2> add
1786+
scratch/main> switch /main
1787+
```
1788+
1789+
``` ucm :error
1790+
scratch/main> merge /topic
1791+
```
1792+
1793+
``` ucm
1794+
scratch/main> switch /merge-topic-into-main
1795+
```
1796+
1797+
``` unison
1798+
type Foo = Bar
1799+
```
1800+
1801+
``` ucm
1802+
scratch/merge-topic-into-main> update
1803+
scratch/main> names Foo
1804+
scratch/topic> names Foo
1805+
scratch/merge-topic-into-main> names Foo
1806+
```
1807+
1808+
``` ucm :error
1809+
scratch/topic> merge /main
1810+
```
1811+
1812+
``` ucm
1813+
scratch/merge-main-into-topic>
1814+
```
1815+
1816+
``` unison
1817+
type Foo = Bar
1818+
```
1819+
1820+
``` ucm
1821+
scratch/merge-main-into-topic> update
1822+
scratch/main> names Foo
1823+
scratch/topic> names Foo
1824+
scratch/merge-main-into-topic> names Foo
1825+
```
1826+
1827+
``` ucm :error
1828+
scratch/topic> merge /topic2
1829+
```
1830+
1831+
``` ucm
1832+
scratch/merge-topic2-into-topic>
1833+
```
1834+
1835+
``` unison
1836+
type Foo = Bar
1837+
```
1838+
1839+
``` ucm
1840+
scratch/merge-topic2-into-topic> update
1841+
scratch/topic> names Foo
1842+
scratch/topic2> names Foo
1843+
scratch/merge-topic2-into-topic> names Foo
1844+
```
1845+
1846+
``` ucm :hide
1847+
scratch/main> project.delete scratch
1848+
```
1849+
17511850
### Using Alice's names for Bob's things
17521851

17531852
Previously, we'd render Alice's stuff with her names and Bob's stuff with his. But because Alice is doing the merge,

0 commit comments

Comments
 (0)