Commit Graph

24 Commits

Author SHA1 Message Date
Sune Foldager
dca90c364e parsers: fix invariant bug in find_deepest (issue5623)
find_deepest is used to find the "best" ancestors given a list. In the main
loop it keeps an invariant called 'ninteresting' which is supposed to contain
the number of non-zero entries in the 'interesting' array. This invariant is
incorrectly maintained, however, which leads the the algorithm returning an
empty result for certain graphs. This has been fixed.

Also, the 'interesting' array is supposed to fit 2^ancestors values, but is
incorrectly allocated to twice that size. This has been fixed as well.

The tests in test-ancestor.py compare the Python and C versions of the code,
and report the error correctly, since the Python version works correct. Even
so, I have added an additional test against the expected result, in the event
that both algorithms have an identical error in the future.

This fixes issue5623.
2017-07-14 13:48:17 +02:00
Pulkit Goyal
baf5959e2c py3: pass the path in hg.repository() as bytes
This make test-ancestor.py pass on Python 3.
2017-06-17 14:39:10 +05:30
Pulkit Goyal
c7a2feb87f py3: pass range() into list() to get one explicitly
range() on python 3 returns a generator whereas on python 2 returns a list. So
to get a list on python 3, we passed it into list()
2017-06-17 14:38:02 +05:30
Pulkit Goyal
fbb85da9c2 py3: alias long to int and xrange to range in test-ancestor.py on Python 3 2017-06-16 01:24:31 +05:30
Martin von Zweigbergk
c3406ac3db cleanup: use set literals
We no longer support Python 2.6, so we can now use set literals.
2017-02-10 16:56:29 -08:00
Yuya Nishihara
1d44bd2bbb ui: factor out ui.load() to create a ui without loading configs (API)
This allows us to write doctests depending on a ui object, but not on global
configs.

ui.load() is a class method so we can do wsgiui.load(). All ui() calls but
for doctests are replaced with ui.load(). Some of them could be changed to
not load configs later.
2016-10-22 14:35:10 +09:00
Gregory Szorc
190f2e7fdb debugcommands: move debugbuilddag
And we drop some now unused imports from commands.py.
2016-11-10 09:45:42 -08:00
Yuya Nishihara
59a0fa579d tests: alias ui as uimod in test-ancestor 2016-04-03 19:48:47 +09:00
Robert Stanca
3ab964e343 py3: use print_function in test-ancestor.py 2016-04-02 17:33:11 +03:00
Gregory Szorc
430d619ce6 tests/test-ancestor: use absolute_import 2015-12-06 22:07:13 -08:00
Siddharth Agarwal
1a87e8b8c3 ancestor: add a way to remove ancestors of bases from a given set
This and missingancestors can share state, which will turn out to be perfect
for set discovery.
2014-11-14 19:40:30 -08:00
Siddharth Agarwal
0d3efeefd2 ancestor: add a way to add to bases of a missing ancestor object
This will be useful for setdiscovery, since with that we incrementally add to
our knowledge of common nodes.
2014-11-14 17:21:00 -08:00
Siddharth Agarwal
b623bd01d1 test-ancestor: add support for multiple tests against one incremental object
In upcoming patches we'll add more operations to the object, and this prepares
for testing those operations.
2014-11-15 19:26:20 -08:00
Siddharth Agarwal
947fdbcb01 test-ancestor: move naive missing ancestor algorithm into a class
This mirrors the change to the real missing ancestor algorithm in a previous
patch.
2014-11-14 23:50:01 -08:00
Siddharth Agarwal
b865bfbae7 ancestor.missingancestors: turn into a state-keeping class
This allows multiple efficient missing ancestor queries against the same set of
bases. In upcoming patches we'll also define ways to grow the set of bases.

The fact that the test output hasn't changed establishes this patch's
correctness.
2014-11-14 23:44:38 -08:00
Siddharth Agarwal
696c998447 test-ancestor: use random testing for missing ancestors
We're going to make changes to the missing ancestor algorithm, and random
testing will give us much more confidence than a fixed set of tests.
2014-11-15 10:55:34 -08:00
Siddharth Agarwal
6696596e68 test-ancestor: define a main function
We're going to add to it in upcoming patches.
2014-11-15 18:52:44 -08:00
Siddharth Agarwal
0f3bd4c81c test-ancestor: test iteration for lazyancestors
This has some test coverage in test-revlog-ancestry.py, but not very much.
2014-11-14 14:50:03 -08:00
Siddharth Agarwal
7103eb28ea ancestor.lazyancestors: take parentrevs function rather than changelog
Principle of least privilege, and it also brings this in line with
missingancestors.
2014-11-14 14:36:25 -08:00
Pierre-Yves David
1f9120a498 test-ancestor: add a test for ancestor with ancestry within the initset
I was wondering if revisions in the initial set that are still ancestors of other
elements in the initial set were yielded by `changelog.ancestors`. I now have my
answer (they do) and Mercurial has a new test.
2014-08-30 11:39:15 +02:00
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
Siddharth Agarwal
52db69329a ancestor.deepest: ignore ninteresting while building result (issue3984)
ninteresting indicates the number of non-zero elements in the interesting
array, not the number of elements in the final list. Since elements in
interesting can stand for more than one gca, limiting the number of results to
ninteresting is an error.

Tests for issue3984 are included.
2013-07-25 14:43:15 -07:00
Siddharth Agarwal
4fdbea480f ancestor: add lazy membership testing to lazyancestors
This also makes the perfancestorset command use lazy membership testing. In a
linear repository with over 400,000 commits, without this patch, hg
perfancestorset takes 0.80 seconds no matter how far behind we're looking.
With this patch, hg perfancestorset -- X takes:

    Rev X       Time
       -1      0.00s
    -4000      0.01s
   -20000      0.04s
   -80000      0.17s
  -200000      0.43s
  -300000      0.69s
        0      0.88s

Thus, for revisions close to tip, we're up to several orders of magnitude
faster. At 0 we're around 10% slower.
2012-12-18 12:47:20 -08:00
Siddharth Agarwal
40a1b50c25 ancestor: move missingancestors doctest out into a separate file
This is in preparation for upcoming patches which will reuse the same graph
for tests.
2012-12-11 14:47:33 -08:00