Given a revision and a set of possible ancestors, finds the one that is the most recent ancestor of the revision; if none are ancestors, returns "".
(revid string, ancestors []string)
| 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 "". |
| 380 | func (tree RevTree) findAncestorFromSet(revid string, ancestors []string) string { |
| 381 | // OPT: This is slow... |
| 382 | for revid != "" { |
| 383 | for _, a := range ancestors { |
| 384 | if a == revid { |
| 385 | return a |
| 386 | } |
| 387 | } |
| 388 | info, err := tree.getInfo(revid) |
| 389 | if err != nil { |
| 390 | break |
| 391 | } |
| 392 | revid = info.Parent |
| 393 | } |
| 394 | return "" |
| 395 | } |
| 396 | |
| 397 | // Records a revision in a RevTree. |
| 398 | func (tree RevTree) addRevision(docid string, info RevInfo) error { |
no test coverage detected