Finds the "winning" revision, the one that should be treated as the default. This is the leaf revision whose (!deleted, generation, hash) tuple compares the highest.
(ctx context.Context)
| 355 | // Finds the "winning" revision, the one that should be treated as the default. |
| 356 | // This is the leaf revision whose (!deleted, generation, hash) tuple compares the highest. |
| 357 | func (tree RevTree) winningRevision(ctx context.Context) (winner string, branched bool, inConflict bool) { |
| 358 | winnerExists := false |
| 359 | leafCount := 0 |
| 360 | activeLeafCount := 0 |
| 361 | tree.forEachLeaf(func(info *RevInfo) { |
| 362 | exists := !info.Deleted |
| 363 | leafCount++ |
| 364 | if exists { |
| 365 | activeLeafCount++ |
| 366 | } |
| 367 | if (exists && !winnerExists) || |
| 368 | ((exists == winnerExists) && compareRevIDs(ctx, info.ID, winner) > 0) { |
| 369 | winner = info.ID |
| 370 | winnerExists = exists |
| 371 | } |
| 372 | }) |
| 373 | branched = (leafCount > 1) |
| 374 | inConflict = (activeLeafCount > 1) |
| 375 | return |
| 376 | } |
| 377 | |
| 378 | // Given a revision and a set of possible ancestors, finds the one that is the most recent |
| 379 | // ancestor of the revision; if none are ancestors, returns "". |