revlog: add a C implementation of `headrevsdiff`
Python implementation of `headrevsdiff` can be very slow in the worst
case compared with the `heads` computation it replaces, since the
latter is done in C.
Even the average case of this Python implementation is still
noticeable in the profiles.
This patch makes the computation much much faster by doing it in C.
import unittest
import silenttestrunner
from mercurial import pathutil
class dirstests(unittest.TestCase):
def testdirs(self):
for case, want in [
(b'a/a/a', [b'a', b'a/a', b'']),
(b'alpha/beta/gamma', [b'', b'alpha', b'alpha/beta']),
]:
d = pathutil.dirs([])
d.addpath(case)
self.assertEqual(sorted(d), sorted(want))
def testinvalid(self):
with self.assertRaises(ValueError):
d = pathutil.dirs([])
d.addpath(b'a//b')
if __name__ == '__main__':
silenttestrunner.main(__name__)