tests/test-hg-parseurl.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Mon, 25 Mar 2024 01:50:31 +0100
branchstable
changeset 51516 e0f92bd98c24
parent 48875 6000f5b25c9b
permissions -rw-r--r--
phases: avoid a potentially costly dictionary interation in some case If we retract for the draft phase, there is not non-public item to be retracted and we can skip this part. This part is was apparently super costly thanks to Python. On mozilla-try-2019-02-18, a perf::unbundle call with a 10 000 changesets bundle gives give use the following timing. e57d4b868a3e: 4.6 seconds ac1c75188440: 102.5 seconds this-changeset: 30.0 seconds So we recovered about ⅔ of the regression, the next changeset will give us the rest back.

import unittest

from mercurial.utils import urlutil


class ParseRequestTests(unittest.TestCase):
    def testparse(self):

        self.assertEqual(
            urlutil.parseurl(b'http://example.com/no/anchor'),
            (b'http://example.com/no/anchor', (None, [])),
        )
        self.assertEqual(
            urlutil.parseurl(b'http://example.com/an/anchor#foo'),
            (b'http://example.com/an/anchor', (b'foo', [])),
        )
        self.assertEqual(
            urlutil.parseurl(
                b'http://example.com/no/anchor/branches', [b'foo']
            ),
            (b'http://example.com/no/anchor/branches', (None, [b'foo'])),
        )
        self.assertEqual(
            urlutil.parseurl(
                b'http://example.com/an/anchor/branches#bar', [b'foo']
            ),
            (b'http://example.com/an/anchor/branches', (b'bar', [b'foo'])),
        )
        self.assertEqual(
            urlutil.parseurl(
                b'http://example.com/an/anchor/branches-None#foo', None
            ),
            (b'http://example.com/an/anchor/branches-None', (b'foo', [])),
        )
        self.assertEqual(
            urlutil.parseurl(b'http://example.com/'),
            (b'http://example.com/', (None, [])),
        )
        self.assertEqual(
            urlutil.parseurl(b'http://example.com'),
            (b'http://example.com/', (None, [])),
        )
        self.assertEqual(
            urlutil.parseurl(b'http://example.com#foo'),
            (b'http://example.com/', (b'foo', [])),
        )


if __name__ == '__main__':
    import silenttestrunner

    silenttestrunner.main(__name__)