Mercurial > hg
annotate tests/test-mdiff.py @ 45562:b51167d70f5a
rust: add `dirstate_tree` module
Mercurial needs to represent the filesystem hierarchy on which it operates, for
example in the dirstate. Its current on-disk representation is an unsorted, flat
structure that gets transformed in the current Rust code into a `HashMap`.
This loses the hierarchical information of the dirstate, leading to some
unfortunate performance and algorithmic compromises.
This module adds an implementation of a radix tree that is specialized for
representing the dirstate: its unit is the path component. I have made no
efforts to optimize either its memory footprint or its insertion speed: they're
pretty bad for now.
Following will be a few patches that modify the dirstate.status logic to use
that new hierarchical information, fixing issue 6335 in the same swing.
Differential Revision: https://phab.mercurial-scm.org/D9085
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Fri, 25 Sep 2020 17:51:34 +0200 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
rev | line source |
---|---|
35862
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 from __future__ import absolute_import |
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 from __future__ import print_function |
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 |
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 import unittest |
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
6 from mercurial import mdiff |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
7 |
35862
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 class splitnewlinesTests(unittest.TestCase): |
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 def test_splitnewlines(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
11 cases = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
12 b'a\nb\nc\n': [b'a\n', b'b\n', b'c\n'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
13 b'a\nb\nc': [b'a\n', b'b\n', b'c'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
14 b'a\nb\nc\n\n': [b'a\n', b'b\n', b'c\n', b'\n'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
15 b'': [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
16 b'abcabc': [b'abcabc'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
17 } |
36327
58c1368ab629
py3: use dict.items() instead of dict.iteritems() in tests
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35862
diff
changeset
|
18 for inp, want in cases.items(): |
35862
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 self.assertEqual(mdiff.splitnewlines(inp), want) |
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
21 |
35862
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 if __name__ == '__main__': |
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 import silenttestrunner |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
36328
diff
changeset
|
24 |
35862
1ab7b16c9437
tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 silenttestrunner.main(__name__) |