Mercurial > public > mercurial-scm > hg
diff mercurial/ancestor.py @ 18079:b3ba69692f8a
ancestor: move missingancestors doctest out into a separate file
This is in preparation for upcoming patches which will reuse the same graph
for tests.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 11 Dec 2012 14:47:33 -0800 |
parents | 09d5681d5b72 |
children | 9abc55ef85b5 |
line wrap: on
line diff
--- a/mercurial/ancestor.py Sun Dec 16 23:02:54 2012 -0600 +++ b/mercurial/ancestor.py Tue Dec 11 14:47:33 2012 -0800 @@ -101,88 +101,6 @@ revs and bases should both be iterables. pfunc must return a list of parent revs for a given revs. - - graph is a dict of child->parent adjacency lists for this graph: - o 13 - | - | o 12 - | | - | | o 11 - | | |\ - | | | | o 10 - | | | | | - | o---+ | 9 - | | | | | - o | | | | 8 - / / / / - | | o | 7 - | | | | - o---+ | 6 - / / / - | | o 5 - | |/ - | o 4 - | | - o | 3 - | | - | o 2 - |/ - o 1 - | - o 0 - >>> graph = {0: [-1], 1: [0], 2: [1], 3: [1], 4: [2], 5: [4], 6: [4], - ... 7: [4], 8: [-1], 9: [6, 7], 10: [5], 11: [3, 7], 12: [9], - ... 13: [8]} - >>> pfunc = graph.get - - Empty revs - >>> missingancestors([], [1], pfunc) - [] - >>> missingancestors([], [], pfunc) - [] - - If bases is empty, it's the same as if it were [nullrev] - >>> missingancestors([12], [], pfunc) - [0, 1, 2, 4, 6, 7, 9, 12] - - Trivial case: revs == bases - >>> missingancestors([0], [0], pfunc) - [] - >>> missingancestors([4, 5, 6], [6, 5, 4], pfunc) - [] - - With nullrev - >>> missingancestors([-1], [12], pfunc) - [] - >>> missingancestors([12], [-1], pfunc) - [0, 1, 2, 4, 6, 7, 9, 12] - - 9 is a parent of 12. 7 is a parent of 9, so an ancestor of 12. 6 is an - ancestor of 12 but not of 7. - >>> missingancestors([12], [9], pfunc) - [12] - >>> missingancestors([9], [12], pfunc) - [] - >>> missingancestors([12, 9], [7], pfunc) - [6, 9, 12] - >>> missingancestors([7, 6], [12], pfunc) - [] - - More complex cases - >>> missingancestors([10], [11, 12], pfunc) - [5, 10] - >>> missingancestors([11], [10], pfunc) - [3, 7, 11] - >>> missingancestors([11], [10, 12], pfunc) - [3, 11] - >>> missingancestors([12], [10], pfunc) - [6, 7, 9, 12] - >>> missingancestors([12], [11], pfunc) - [6, 9, 12] - >>> missingancestors([10, 11, 12], [13], pfunc) - [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12] - >>> missingancestors([13], [10, 11, 12], pfunc) - [8, 13] """ revsvisit = set(revs)