Mercurial > hg
annotate tests/test-hg-parseurl.py @ 47072:4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Since the dawn of time, people have been forced to rely to lossy introspection
of the index filename to determine what the purpose and role of the revlog they
encounter is. This is hacky, error prone, inflexible, abstraction-leaky,
<insert-your-own-complaints-here>.
In f63299ee7e4d Raphaël introduced a new attribute to track this information:
`revlog_kind`. However it is initialized in an odd place and various instances
end up not having it set. In addition is only tracking some of the information
we end up having to introspect in various pieces of code.
So we add a new attribute that holds more data and is more strictly enforced.
This work is done in collaboration with Raphaël.
The `revlog_kind` one will be removed/adapted in the next changeset. We expect
to be able to clean up various existing piece of code and to simplify coming
work around the newer revlog format.
Differential Revision: https://phab.mercurial-scm.org/D10352
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 06 Apr 2021 05:20:24 +0200 |
parents | 4452cb788404 |
children | 6000f5b25c9b |
rev | line source |
---|---|
28746
de5808c57f58
py3: use print_function in test-hg-parseurl.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28745
diff
changeset
|
1 from __future__ import absolute_import, print_function |
28806
d26c4af27978
test-hg-parseurl: stop direct symbol import of mercurial.hg.parseurl
Yuya Nishihara <yuya@tcha.org>
parents:
28746
diff
changeset
|
2 |
37713
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
3 import unittest |
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
4 |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
5 from mercurial.utils import urlutil |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
6 |
8174
29bc5d18714a
hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
7 |
37713
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
8 class ParseRequestTests(unittest.TestCase): |
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
9 def testparse(self): |
8174
29bc5d18714a
hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
10 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
11 self.assertEqual( |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
12 urlutil.parseurl(b'http://example.com/no/anchor'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
13 (b'http://example.com/no/anchor', (None, [])), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
14 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
15 self.assertEqual( |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
16 urlutil.parseurl(b'http://example.com/an/anchor#foo'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
17 (b'http://example.com/an/anchor', (b'foo', [])), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
18 ) |
37713
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
19 self.assertEqual( |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
20 urlutil.parseurl( |
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
21 b'http://example.com/no/anchor/branches', [b'foo'] |
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
22 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
23 (b'http://example.com/no/anchor/branches', (None, [b'foo'])), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
24 ) |
37713
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
25 self.assertEqual( |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
26 urlutil.parseurl( |
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
27 b'http://example.com/an/anchor/branches#bar', [b'foo'] |
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
28 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
29 (b'http://example.com/an/anchor/branches', (b'bar', [b'foo'])), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
30 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
31 self.assertEqual( |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
32 urlutil.parseurl( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
33 b'http://example.com/an/anchor/branches-None#foo', None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
34 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
35 (b'http://example.com/an/anchor/branches-None', (b'foo', [])), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
36 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
37 self.assertEqual( |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
38 urlutil.parseurl(b'http://example.com/'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
39 (b'http://example.com/', (None, [])), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
40 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
41 self.assertEqual( |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
42 urlutil.parseurl(b'http://example.com'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
43 (b'http://example.com/', (None, [])), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
44 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
45 self.assertEqual( |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43076
diff
changeset
|
46 urlutil.parseurl(b'http://example.com#foo'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
47 (b'http://example.com/', (b'foo', [])), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
48 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
49 |
37713
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
50 |
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
51 if __name__ == '__main__': |
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
52 import silenttestrunner |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37714
diff
changeset
|
53 |
37713
11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents:
28806
diff
changeset
|
54 silenttestrunner.main(__name__) |