Mercurial > hg
annotate tests/test-dirs.py @ 49510:e02dcc625171
revset: handle wdir() in `roots()`
This is already handled in `heads()`, and both are needed to determine if a set
is contiguous.
I'm guessing the `0 <= p` check was to try to filter out the null revision, but
it looks like that comes through in the corner case of a new repo with no
commits. But that was already the case, as shown by the tests.
Before (on a clone of hg):
$ python3.8 hg perf::revset --config extensions.perf=contrib/perf.py 'roots(all())'
! wall 0.059301 comb 0.040000 user 0.040000 sys 0.000000 (best of 100)
After:
$ python3.8 hg perf::revset --config extensions.perf=contrib/perf.py 'roots(all())'
! wall 0.059387 comb 0.060000 user 0.060000 sys 0.000000 (best of 100)
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 03 Oct 2022 17:24:52 -0400 |
parents | 6000f5b25c9b |
children |
rev | line source |
---|---|
43494
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 import unittest |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 import silenttestrunner |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 |
43523
c21aca51b392
utils: move the `dirs` definition in pathutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43494
diff
changeset
|
5 from mercurial import pathutil |
43494
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 class dirstests(unittest.TestCase): |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 def testdirs(self): |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 for case, want in [ |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 (b'a/a/a', [b'a', b'a/a', b'']), |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 (b'alpha/beta/gamma', [b'', b'alpha', b'alpha/beta']), |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 ]: |
48021
627cd8f33db0
rust: Remove support for passing a dict to the Rust pathutil.dirs()
Simon Sapin <simon.sapin@octobus.net>
parents:
43523
diff
changeset
|
14 d = pathutil.dirs([]) |
43494
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 d.addpath(case) |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 self.assertEqual(sorted(d), sorted(want)) |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 def testinvalid(self): |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 with self.assertRaises(ValueError): |
48021
627cd8f33db0
rust: Remove support for passing a dict to the Rust pathutil.dirs()
Simon Sapin <simon.sapin@octobus.net>
parents:
43523
diff
changeset
|
20 d = pathutil.dirs([]) |
43494
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 d.addpath(b'a//b') |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 if __name__ == '__main__': |
5d40317d42b7
dirs: reject consecutive slashes in paths
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 silenttestrunner.main(__name__) |