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
Straighten multiple segments, including when there are commits #11059
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are 🔥
Few nits
@@ -508,9 +508,11 @@ static void StraightenLanes(int startIndex, int lastStraightenIndex, int lastLoo | |||
|
|||
int straightenedCurrentLane = currentLane + 1; | |||
int lookaheadLane = currentLane; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int lookaheadLane = currentLane; | |
int lookAheadLane = currentLane; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- int lookaheadLane = currentLane;
+ int lookAheadLane = currentLane;
Then we would need to change the capitalization of the existing lookaheadIndex
, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
for (int lookaheadIndex = currentIndex + 1; lookaheadLane == currentLane && lookaheadIndex <= Math.Min(currentIndex + _straightenLanesLookAhead, lastLookaheadIndex); ++lookaheadIndex) | ||
{ | ||
lookaheadLane = localOrderedRowCache[lookaheadIndex].GetLaneForSegment(revisionGraphSegment).Index; | ||
RevisionGraphRow lookaheadRow = localOrderedRowCache[lookaheadIndex]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RevisionGraphRow lookaheadRow = localOrderedRowCache[lookaheadIndex]; | |
RevisionGraphRow lookAheadRow = localOrderedRowCache[lookaheadIndex]; |
private static void AssertGraphLayout(RevisionGraph revisionGraph, string expectedLayout) | ||
{ | ||
string expectedGraph = expectedLayout.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Join("\n"); | ||
string actualGraph = AsciiGraphFor(revisionGraph).Join("\n"); | ||
try | ||
{ | ||
Assert.AreEqual(expectedGraph, actualGraph); | ||
} | ||
catch | ||
{ | ||
Console.WriteLine(actualGraph); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered using snapshot testing instead (i.e., Verify)? This way the diff would be visual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The display (of Console.WriteLine
output) in the test explorer is not perfect, but was good enough for me when using o-kloster's test utility.
Though it is very useful to have the graph definition and the expected result in one place:
RevisionGraph revisionGraph = CreateGraph("R 4:R 3:R 2:R,3 1:2 0:1,4");
AssertGraphLayout(revisionGraph, @"
0
|\
1 |
| \
2 |
|\ |
| 3 |
| | |
| | 4
|/-´
R
");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The display (of
Console.WriteLine
output) in the test explorer is not perfect, but was good enough for me when using o-kloster's test utility. Though it is very useful to have the graph definition and the expected result in one place:RevisionGraph revisionGraph = CreateGraph("R 4:R 3:R 2:R,3 1:2 0:1,4"); AssertGraphLayout(revisionGraph, @" 0 |\ 1 | | \ 2 | |\ | | 3 | | | | | | 4 |/-´ R ");
I am still convinced that this is better tp be kept in one place than fiddling around with lots of .verified.txt
files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
than fiddling around with lots of
.verified.txt
files.
That's the key point - there's no fiddling required, the verified files are updated automatically. First, if the test result is different from the expectation, you'll see it in a diff tool. Then, if the change is expected, then the new version is applied in the diff tool.
042821e
to
ab8b642
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do net see a difference in the screenshots (which seem to have been taken with this PR). What would you expect? |
Bad screenshot, updated. I expected the gap to be filled, there is nothing at all in that column. |
Straightened lanes are bought by inserting gaps. |
Co-authored-by: Igor Velikorossov <russkie@gmail.com>
2214231
to
80fde7e
Compare
Fixes #5782
Improves on #9050
The essence of #10778 by @o-kloster including the very useful test utility
Proposed changes
Screenshots
Before
After
Test methodology
Merge strategy
I agree that the maintainer squash merge this PR (if the commit message is clear).
✒️ I contribute this code under The Developer Certificate of Origin.