Пример #1
0
def test_gca():
    u = uimod.ui.load()
    for i, (dag, tests) in enumerate(dagtests):
        repo = hg.repository(u, b'gca%d' % i, create=1)
        cl = repo.changelog
        if not util.safehasattr(cl.index, 'ancestors'):
            # C version not available
            return

        debugcommands.debugbuilddag(u, repo, dag)
        # Compare the results of the Python and C versions. This does not
        # include choosing a winner when more than one gca exists -- we make
        # sure both return exactly the same set of gcas.
        # Also compare against expected results, if available.
        for a in cl:
            for b in cl:
                cgcas = sorted(cl.index.ancestors(a, b))
                pygcas = sorted(ancestor.ancestors(cl.parentrevs, a, b))
                expected = None
                if (a, b) in tests:
                    expected = tests[(a, b)]
                if cgcas != pygcas or (expected and cgcas != expected):
                    print("test_gca: for dag %s, gcas for %d, %d:"
                          % (dag, a, b))
                    print("  C returned:      %s" % cgcas)
                    print("  Python returned: %s" % pygcas)
                    if expected:
                        print("  expected:        %s" % expected)
Пример #2
0
 def ancestor(self, a, b):
     anode = self.repo.nodemap.get(a)
     bnode = self.repo.nodemap.get(b)
     if anode is None and bnode is None:
         return self.base.ancestor(a, b)
     ancs = ancestor.ancestors(self.parentrevs, a, b)
     if ancs:
         return min(map(self.node, ancs))
     return nullid
Пример #3
0
 def ancestor(self, a, b):
     anode = self.repo.nodemap.get(a)
     bnode = self.repo.nodemap.get(b)
     if anode is None and bnode is None:
       return self.base.ancestor(a, b)
     ancs = ancestor.ancestors(self.parentrevs, a, b)
     if ancs:
       return min(map(self.node, ancs))
     return nullid
Пример #4
0
    def ancestor(self, a, b):
        if a == nullid or b == nullid:
            return nullid

        revmap, parentfunc = self._buildrevgraph(a, b)
        nodemap = {v: k for (k, v) in pycompat.iteritems(revmap)}

        ancs = ancestor.ancestors(parentfunc, revmap[a], revmap[b])
        if ancs:
            # choose a consistent winner when there's a tie
            return min(map(nodemap.__getitem__, ancs))
        return nullid
Пример #5
0
    def ancestor(self, a, b):
        if a == nullid or b == nullid:
            return nullid

        revmap, parentfunc = self._buildrevgraph(a, b)
        nodemap = dict(((v, k) for (k, v) in revmap.iteritems()))

        ancs = ancestor.ancestors(parentfunc, revmap[a], revmap[b])
        if ancs:
            # choose a consistent winner when there's a tie
            return min(map(nodemap.__getitem__, ancs))
        return nullid
Пример #6
0
def test_gca():
    u = ui.ui()
    for i, dag in enumerate(dagtests):
        repo = hg.repository(u, "gca%d" % i, create=1)
        cl = repo.changelog
        if not util.safehasattr(cl.index, "ancestors"):
            # C version not available
            return

        commands.debugbuilddag(u, repo, dag)
        # Compare the results of the Python and C versions. This does not
        # include choosing a winner when more than one gca exists -- we make
        # sure both return exactly the same set of gcas.
        for a in cl:
            for b in cl:
                cgcas = sorted(cl.index.ancestors(a, b))
                pygcas = sorted(ancestor.ancestors(cl.parentrevs, a, b))
                if cgcas != pygcas:
                    print "test_gca: for dag %s, gcas for %d, %d:" % (dag, a, b)
                    print "  C returned:      %s" % cgcas
                    print "  Python returned: %s" % pygcas
Пример #7
0
def test_gca():
    u = ui.ui()
    for i, dag in enumerate(dagtests):
        repo = hg.repository(u, 'gca%d' % i, create=1)
        cl = repo.changelog
        if not util.safehasattr(cl.index, 'ancestors'):
            # C version not available
            return

        commands.debugbuilddag(u, repo, dag)
        # Compare the results of the Python and C versions. This does not
        # include choosing a winner when more than one gca exists -- we make
        # sure both return exactly the same set of gcas.
        for a in cl:
            for b in cl:
                cgcas = sorted(cl.index.ancestors(a, b))
                pygcas = sorted(ancestor.ancestors(cl.parentrevs, a, b))
                if cgcas != pygcas:
                    print "test_gca: for dag %s, gcas for %d, %d:" % (dag, a,
                                                                      b)
                    print "  C returned:      %s" % cgcas
                    print "  Python returned: %s" % pygcas