Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Add FindCommonAncestor for Commits #2579

Merged
merged 4 commits into from
Sep 15, 2016

Conversation

cmasone-attic
Copy link
Contributor

Once we integrate noms-merge into the noms commit command, this
function will allow us to stop requiring users to pass in the common
ancestor to be used when merging. The code can just find it and merge
away.

Toward #2535

Once we integrate noms-merge into the `noms commit` command, this
function will allow us to stop requiring users to pass in the common
ancestor to be used when merging. The code can just find it and merge
away.

Toward attic-labs#2535
@cmasone-attic
Copy link
Contributor Author

PTAL

@codecov-io
Copy link

codecov-io commented Sep 15, 2016

Current coverage is 81.51% (diff: 97.67%)

No coverage report found for master at 7d9c373.

Powered by Codecov. Last update 7d9c373...b8f0319

Instead of building Noms Sets out of parents and using an
IntersectionIterator (overkill), make a Go map by TargetHash
instead.
@cmasone-attic
Copy link
Contributor Author

PTAL

for i, r := range refs {
vals[i] = r
}
return types.NewSet(vals...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said IRL: try using TargetHash().String() of these refs and put in a Go map, not types.Set.

@@ -66,6 +68,50 @@ func CommitDescendsFrom(commit types.Struct, ancestor types.Ref, vr types.ValueR
return true
}

// FindCommonAncestor returns the most recent common ancestor of c1 and c2, if
// one exists, setting ok to true. If there is no common ancestor, ok is set to false.
func FindCommonAncestor(c1, c2 types.Struct, vr types.ValueReader) (a types.Struct, ok bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these structs because they are supposed to be Commits? Could you do d.PanicIfFalse(IsCommitType(c1.Type()) then?

(maybe we should add an IsCommitStruct so you don't need to call .Type())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@kalman kalman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@cmasone-attic cmasone-attic merged commit 96cc9ff into attic-labs:master Sep 15, 2016
@cmasone-attic cmasone-attic deleted the findp branch September 17, 2016 00:02
ehalpern pushed a commit to ehalpern/noms that referenced this pull request Sep 20, 2016
* 'master' of github.com:attic-labs/noms: (51 commits)
  Add unit tests for commit metadata (attic-labs#2595)
  Tweak the display of the type of an empty Map (attic-labs#2590)
  Remove TypeDesc equals (attic-labs#2584)
  Blackbg (attic-labs#2586)
  Make codecov Slack integration not emit 'template string' (attic-labs#2585)
  Go sequence interface/struct hierarchy refactor (attic-labs#2583)
  Update run_perf_builder.py to run 'go test' commands sequentially (attic-labs#2582)
  Add FindCommonAncestor for Commits (attic-labs#2579)
  Improve Go merge package code coverage (attic-labs#2581)
  Add code coverage to js/noms too (attic-labs#2580)
  Run python unittests; configure codecov via YAML (attic-labs#2578)
  Add codecov.io badge and submit coverage data from builds (attic-labs#2577)
  Add comment referencing potential infinite Commit loop (attic-labs#2576)
  Add link to download Noms binaries (attic-labs#2573)
  Add go/types/perf to perf build tests (oops) (attic-labs#2572)
  Support multiple perf datasets in the perf UI (attic-labs#2571)
  Add go/types to perf builder tests (attic-labs#2568)
  Build go binaries for multiple platforms (attic-labs#2564)
  Introduce List.Concat to the Go API (attic-labs#2550)
  Allow changes to different Datasets to proceed concurrently (attic-labs#2533)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants