Mercurial > hg
annotate tests/test-hgwebdir-paths.py @ 43961:b69d5f3a41d0
rust-index: add a struct wrapping the C index
Implementing the full index logic in one go is journey larger than we would
like.
To achieve a smoother transition, we start with a simple Rust wrapper that delegates
allwork to the current C implementation. Once we will have a fully working index
object in Rust, we can easily start using more and more Rust Code with it.
The object in this patch is functional and tested. However, multiple of the
currently existing rust (in the `hg-cpython` crate) requires a `Graph`. Right
now we build this `Graph` (as cindex::Index) using the C index passed as
a PyObject. They will have to be updated to be made compatible.
Differential Revision: https://phab.mercurial-scm.org/D7655
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Mon, 23 Dec 2019 10:02:50 -0800 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
rev | line source |
---|---|
28932
4eac86331acb
tests: make test-hgwebdir-paths use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
15381
diff
changeset
|
1 from __future__ import absolute_import |
4eac86331acb
tests: make test-hgwebdir-paths use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
15381
diff
changeset
|
2 |
8529
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
3 import os |
28932
4eac86331acb
tests: make test-hgwebdir-paths use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
15381
diff
changeset
|
4 from mercurial import ( |
4eac86331acb
tests: make test-hgwebdir-paths use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
15381
diff
changeset
|
5 hg, |
4eac86331acb
tests: make test-hgwebdir-paths use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
15381
diff
changeset
|
6 ui as uimod, |
4eac86331acb
tests: make test-hgwebdir-paths use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
15381
diff
changeset
|
7 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37879
diff
changeset
|
8 from mercurial.hgweb import hgwebdir_mod |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37879
diff
changeset
|
9 |
28932
4eac86331acb
tests: make test-hgwebdir-paths use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
15381
diff
changeset
|
10 hgwebdir = hgwebdir_mod.hgwebdir |
8529
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
11 |
37879
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
12 os.mkdir(b'webdir') |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
13 os.chdir(b'webdir') |
8529
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
14 |
37879
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
15 webdir = os.path.realpath(b'.') |
8529
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
16 |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28932
diff
changeset
|
17 u = uimod.ui.load() |
37879
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
18 hg.repository(u, b'a', create=1) |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
19 hg.repository(u, b'b', create=1) |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
20 os.chdir(b'b') |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
21 hg.repository(u, b'd', create=1) |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
22 os.chdir(b'..') |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
23 hg.repository(u, b'c', create=1) |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
24 os.chdir(b'..') |
8529
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
25 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37879
diff
changeset
|
26 paths = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37879
diff
changeset
|
27 b't/a/': b'%s/a' % webdir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37879
diff
changeset
|
28 b'b': b'%s/b' % webdir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37879
diff
changeset
|
29 b'coll': b'%s/*' % webdir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37879
diff
changeset
|
30 b'rcoll': b'%s/**' % webdir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37879
diff
changeset
|
31 } |
8529
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
32 |
37879
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
33 config = os.path.join(webdir, b'hgwebdir.conf') |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
34 configfile = open(config, 'wb') |
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
35 configfile.write(b'[paths]\n') |
8529
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
36 for k, v in paths.items(): |
37879
81455f482478
tests: port test-hgwebdir-paths.py to Python 3
Augie Fackler <augie@google.com>
parents:
30559
diff
changeset
|
37 configfile.write(b'%s = %s\n' % (k, v)) |
8529
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
38 configfile.close() |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
39 |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
40 confwd = hgwebdir(config) |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
41 dictwd = hgwebdir(paths) |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
42 |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
43 assert len(confwd.repos) == len(dictwd.repos), 'different numbers' |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
44 assert len(confwd.repos) == 9, 'expected 9 repos, found %d' % len(confwd.repos) |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
45 |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
46 found = dict(confwd.repos) |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
47 for key, path in dictwd.repos: |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
48 assert key in found, 'repository %s was not found' % key |
a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff
changeset
|
49 assert found[key] == path, 'different paths for repo %s' % key |