Skip to content

Introduce ObjectDatabase.CalculateHistoryDivergence() #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2013

Conversation

nulltoken
Copy link
Member

Fix #562

  • Review
  • Xml documentation


aheadBehind = new Lazy<Tuple<int?, int?>>(ResolveAheadBehind);
commonAncestor = new Lazy<Commit>(ResolveCommonAncestor);
HistoryDivergence div = repo.ObjectDatabase.CalculateHistoryDivergence(branch.Tip, branch.TrackedBranch.Tip);
Copy link
Member

Choose a reason for hiding this comment

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

The need to check for null above strikes me as rather inconvenient - what if CalculateHistoryDivergence() just returned an empty HistoryDivergence if either side is null?

Your code here could then be as simple as:

this.div = branch.IsTracking ? repo.ObjectDatabase.Calculate... : new HistoryDivergence();

And each property here would simply defer to div.

Copy link
Member Author

Choose a reason for hiding this comment

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

As it's quite a lower level method, I'd rather keep CalculateHistoryDivergence() expect valid Commits to work with.

I've pushed some additional commits to actually delegate more to the HistoryDivergence type. How does those feel?

I agree with you, though, that the null checks are pretty ugly. Any idea about how to make this prettier?

@dahlbyk
Copy link
Member

dahlbyk commented Nov 18, 2013

How does those feel?

Better

I agree with you, though, that the null checks are pretty ugly. Any idea about how to make this prettier?

Not really - any change would just move the null checks somewhere else.

@@ -235,5 +235,13 @@ public virtual TagAnnotation CreateTagAnnotation(string name, GitObject target,

return repo.Lookup<TagAnnotation>(tagId);
}

public virtual HistoryDivergence CalculateHistoryDivergence(Commit one, Commit another)
Copy link
Member Author

Choose a reason for hiding this comment

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

@dahlbyk @carlosmn I'm really lacking some inspiration about how to express what this method does/returns. Any help would be greatly appreciated.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about

Retrieves some details about the graph relationship between those
two commits such as their best ancestor, if any, and the distance from this latter and the commits

/cc @ethomson @jamill @ben

Copy link
Member

Choose a reason for hiding this comment

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

Some details but not others?

Returns the merge base (best common ancestor) of the given commits and the distance between each commit and this base.

maybe?

Copy link
Member

Choose a reason for hiding this comment

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

Returns the merge base (best common ancestor) of the given commits and the distance between each commit and this base.

This is nice.

Copy link
Member

Choose a reason for hiding this comment

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

What @ethomson said.

Copy link
Member

Choose a reason for hiding this comment

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

I'd say amend to say "distance between each of these commits", as "each commit" sounds odd now.

Copy link
Member

Choose a reason for hiding this comment

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

👍 for @carlosmn's suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

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

@carlosmn The NameWhisperer

@nulltoken
Copy link
Member Author

Ok. I've rebased this and added some xml documentation. Does it make sense?

@nulltoken nulltoken merged commit a845db9 into vNext Dec 6, 2013
@nulltoken nulltoken deleted the ntk/topic/history_divergence branch December 6, 2013 06:13
@dahlbyk
Copy link
Member

dahlbyk commented Dec 6, 2013

🎱

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants