Skip to content

Commit

Permalink
Merge pull request ipfs/go-merkledag#70 from ipfs/web3-bot/sync
Browse files Browse the repository at this point in the history
sync: update CI config files

This commit was moved from ipfs/go-merkledag@151483a
  • Loading branch information
Stebalien authored Jul 20, 2021
2 parents bd9c144 + d229bf7 commit ab33100
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
18 changes: 11 additions & 7 deletions ipld/merkledag/dagutils/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,28 @@ type Conflict struct {
// Changes involved (which share the same path).
func MergeDiffs(a, b []*Change) ([]*Change, []Conflict) {
paths := make(map[string]*Change)
for _, c := range a {
for _, c := range b {
paths[c.Path] = c
}

var changes []*Change
var conflicts []Conflict

for _, changeB := range b {
if changeA, ok := paths[changeB.Path]; ok {
// NOTE: we avoid iterating over maps here to ensure iteration order is determistic. We
// include changes from a first, then b.
for _, changeA := range a {
if changeB, ok := paths[changeA.Path]; ok {
conflicts = append(conflicts, Conflict{changeA, changeB})
} else {
changes = append(changes, changeB)
changes = append(changes, changeA)
}
delete(paths, changeB.Path)
delete(paths, changeA.Path)
}

for _, c := range paths {
changes = append(changes, c)
for _, c := range b {
if _, ok := paths[c.Path]; ok {
changes = append(changes, c)
}
}

return changes, conflicts
Expand Down
2 changes: 1 addition & 1 deletion ipld/merkledag/dagutils/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func TestMergeDiffs(t *testing.T) {
}

expect := []*Change{
changesB[1],
changesA[0],
changesA[2],
changesB[1],
}

for i, change := range changes {
Expand Down
36 changes: 18 additions & 18 deletions ipld/merkledag/dagutils/diffenum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,61 +46,61 @@ func mkGraph(desc map[string]ndesc) map[string]ipld.Node {
}

var tg1 = map[string]ndesc{
"a1": ndesc{
"a1": {
"foo": "b",
},
"b": ndesc{},
"a2": ndesc{
"b": {},
"a2": {
"foo": "b",
"bar": "c",
},
"c": ndesc{},
"c": {},
}

var tg2 = map[string]ndesc{
"a1": ndesc{
"a1": {
"foo": "b",
},
"b": ndesc{},
"a2": ndesc{
"b": {},
"a2": {
"foo": "b",
"bar": "c",
},
"c": ndesc{"baz": "d"},
"d": ndesc{},
"c": {"baz": "d"},
"d": {},
}

var tg3 = map[string]ndesc{
"a1": ndesc{
"a1": {
"foo": "b",
"bar": "c",
},
"b": ndesc{},
"a2": ndesc{
"b": {},
"a2": {
"foo": "b",
"bar": "d",
},
"c": ndesc{},
"d": ndesc{},
"c": {},
"d": {},
}

var tg4 = map[string]ndesc{
"a1": ndesc{
"a1": {
"key1": "b",
"key2": "c",
},
"a2": ndesc{
"a2": {
"key1": "b",
"key2": "d",
},
}

var tg5 = map[string]ndesc{
"a1": ndesc{
"a1": {
"key1": "a",
"key2": "b",
},
"a2": ndesc{
"a2": {
"key1": "c",
"key2": "d",
},
Expand Down
10 changes: 5 additions & 5 deletions ipld/merkledag/merkledag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ func TestFetchGraphWithDepthLimit(t *testing.T) {
}

tests := []testcase{
testcase{1, 4},
testcase{0, 1},
testcase{-1, 6},
testcase{2, 6},
testcase{3, 6},
{1, 4},
{0, 1},
{-1, 6},
{2, 6},
{3, 6},
}

testF := func(t *testing.T, tc testcase) {
Expand Down

0 comments on commit ab33100

Please sign in to comment.