tests/test-hg-parseurl.py
author Arseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 26 Apr 2024 19:10:35 +0100
changeset 51626 865efc020c33
parent 48875 6000f5b25c9b
permissions -rw-r--r--
dirstate: remove the python-side whitelist of allowed matchers This whitelist is too permissive because it allows matchers that contain disallowed ones deep inside, for example through `intersectionmatcher`. It is also too restrictive because it doesn't pass through some of the matchers we support, such as `patternmatcher`. It's also unnecessary because unsupported matchers raise `FallbackError` and we fall back anyway. Making this change makes more of the tests use rust code path, and therefore subtly change behavior. For example, rust status in largefiles repos seems to have strange behavior.

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__)