tests/test-ancestor.py
author Siddharth Agarwal <sid0@fb.com>
Sat, 15 Nov 2014 18:52:44 -0800
changeset 23330 37c3731d8a58
parent 23329 c6cd4b8b76f8
child 23331 3b1b8f25443e
permissions -rw-r--r--
test-ancestor: define a main function We're going to add to it in upcoming patches.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19504
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
     1
from mercurial import ancestor, commands, hg, ui, util
18079
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     2
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     3
# graph is a dict of child->parent adjacency lists for this graph:
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     4
# o  13
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     5
# |
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     6
# | o  12
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     7
# | |
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     8
# | | o    11
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     9
# | | |\
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    10
# | | | | o  10
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    11
# | | | | |
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    12
# | o---+ |  9
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    13
# | | | | |
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    14
# o | | | |  8
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    15
#  / / / /
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    16
# | | o |  7
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    17
# | | | |
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    18
# o---+ |  6
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    19
#  / / /
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    20
# | | o  5
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    21
# | |/
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    22
# | o  4
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    23
# | |
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    24
# o |  3
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    25
# | |
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    26
# | o  2
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    27
# |/
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    28
# o  1
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    29
# |
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    30
# o  0
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    31
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    32
graph = {0: [-1], 1: [0], 2: [1], 3: [1], 4: [2], 5: [4], 6: [4],
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    33
         7: [4], 8: [-1], 9: [6, 7], 10: [5], 11: [3, 7], 12: [9],
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    34
         13: [8]}
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    35
pfunc = graph.get
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    36
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    37
def runmissingancestors(revs, bases):
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    38
    print "%% ancestors of %s and not of %s" % (revs, bases)
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    39
    print ancestor.missingancestors(revs, bases, pfunc)
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    40
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    41
def test_missingancestors():
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    42
    # Empty revs
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    43
    runmissingancestors([], [1])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    44
    runmissingancestors([], [])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    45
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    46
    # If bases is empty, it's the same as if it were [nullrev]
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    47
    runmissingancestors([12], [])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    48
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    49
    # Trivial case: revs == bases
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    50
    runmissingancestors([0], [0])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    51
    runmissingancestors([4, 5, 6], [6, 5, 4])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    52
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    53
    # With nullrev
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    54
    runmissingancestors([-1], [12])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    55
    runmissingancestors([12], [-1])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    56
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    57
    # 9 is a parent of 12. 7 is a parent of 9, so an ancestor of 12. 6 is an
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    58
    # ancestor of 12 but not of 7.
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    59
    runmissingancestors([12], [9])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    60
    runmissingancestors([9], [12])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    61
    runmissingancestors([12, 9], [7])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    62
    runmissingancestors([7, 6], [12])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    63
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    64
    # More complex cases
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    65
    runmissingancestors([10], [11, 12])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    66
    runmissingancestors([11], [10])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    67
    runmissingancestors([11], [10, 12])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    68
    runmissingancestors([12], [10])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    69
    runmissingancestors([12], [11])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    70
    runmissingancestors([10, 11, 12], [13])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    71
    runmissingancestors([13], [10, 11, 12])
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    72
18091
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    73
def genlazyancestors(revs, stoprev=0, inclusive=False):
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    74
    print ("%% lazy ancestor set for %s, stoprev = %s, inclusive = %s" %
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    75
           (revs, stoprev, inclusive))
23328
3a7d9c0c57a5 ancestor.lazyancestors: take parentrevs function rather than changelog
Siddharth Agarwal <sid0@fb.com>
parents: 22355
diff changeset
    76
    return ancestor.lazyancestors(graph.get, revs, stoprev=stoprev,
18091
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    77
                                  inclusive=inclusive)
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    78
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    79
def printlazyancestors(s, l):
23329
c6cd4b8b76f8 test-ancestor: test iteration for lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 23328
diff changeset
    80
    print 'membership: %r' % [n for n in l if n in s]
c6cd4b8b76f8 test-ancestor: test iteration for lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 23328
diff changeset
    81
    print 'iteration:  %r' % list(s)
18091
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    82
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    83
def test_lazyancestors():
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    84
    # Empty revs
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    85
    s = genlazyancestors([])
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    86
    printlazyancestors(s, [3, 0, -1])
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    87
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    88
    # Standard example
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    89
    s = genlazyancestors([11, 13])
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    90
    printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0])
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    91
22355
731b2a90983b test-ancestor: add a test for `ancestor` with ancestry within the initset
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21024
diff changeset
    92
    # Standard with ancestry in the initial set (1 is ancestor of 3)
731b2a90983b test-ancestor: add a test for `ancestor` with ancestry within the initset
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21024
diff changeset
    93
    s = genlazyancestors([1, 3])
731b2a90983b test-ancestor: add a test for `ancestor` with ancestry within the initset
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21024
diff changeset
    94
    printlazyancestors(s, [1, -1, 0])
731b2a90983b test-ancestor: add a test for `ancestor` with ancestry within the initset
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21024
diff changeset
    95
18091
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    96
    # Including revs
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    97
    s = genlazyancestors([11, 13], inclusive=True)
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    98
    printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0])
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
    99
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
   100
    # Test with stoprev
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
   101
    s = genlazyancestors([11, 13], stoprev=6)
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
   102
    printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0])
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
   103
    s = genlazyancestors([11, 13], stoprev=6, inclusive=True)
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
   104
    printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0])
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
   105
19504
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   106
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   107
# The C gca algorithm requires a real repo. These are textual descriptions of
21024
7731a2281cf0 spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents: 19504
diff changeset
   108
# DAGs that have been known to be problematic.
19504
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   109
dagtests = [
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   110
    '+2*2*2/*3/2',
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   111
    '+3*3/*2*2/*4*4/*4/2*4/2*2',
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   112
]
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   113
def test_gca():
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   114
    u = ui.ui()
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   115
    for i, dag in enumerate(dagtests):
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   116
        repo = hg.repository(u, 'gca%d' % i, create=1)
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   117
        cl = repo.changelog
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   118
        if not util.safehasattr(cl.index, 'ancestors'):
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   119
            # C version not available
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   120
            return
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   121
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   122
        commands.debugbuilddag(u, repo, dag)
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   123
        # Compare the results of the Python and C versions. This does not
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   124
        # include choosing a winner when more than one gca exists -- we make
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   125
        # sure both return exactly the same set of gcas.
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   126
        for a in cl:
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   127
            for b in cl:
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   128
                cgcas = sorted(cl.index.ancestors(a, b))
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   129
                pygcas = sorted(ancestor.ancestors(cl.parentrevs, a, b))
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   130
                if cgcas != pygcas:
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   131
                    print "test_gca: for dag %s, gcas for %d, %d:" % (dag, a, b)
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   132
                    print "  C returned:      %s" % cgcas
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   133
                    print "  Python returned: %s" % pygcas
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   134
23330
37c3731d8a58 test-ancestor: define a main function
Siddharth Agarwal <sid0@fb.com>
parents: 23329
diff changeset
   135
def main():
18079
b3ba69692f8a ancestor: move missingancestors doctest out into a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
   136
    test_missingancestors()
18091
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18079
diff changeset
   137
    test_lazyancestors()
19504
2fa303619b4d ancestor.deepest: ignore ninteresting while building result (issue3984)
Siddharth Agarwal <sid0@fb.com>
parents: 18091
diff changeset
   138
    test_gca()
23330
37c3731d8a58 test-ancestor: define a main function
Siddharth Agarwal <sid0@fb.com>
parents: 23329
diff changeset
   139
37c3731d8a58 test-ancestor: define a main function
Siddharth Agarwal <sid0@fb.com>
parents: 23329
diff changeset
   140
if __name__ == '__main__':
37c3731d8a58 test-ancestor: define a main function
Siddharth Agarwal <sid0@fb.com>
parents: 23329
diff changeset
   141
    main()