swh.loader.mercurial 3.5.0__py3-none-any.whl → 3.5.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swh/loader/mercurial/directory.py +14 -3
- swh/loader/mercurial/hgutil.py +1 -1
- swh/loader/mercurial/tests/test_directory.py +31 -12
- {swh.loader.mercurial-3.5.0.dist-info → swh.loader.mercurial-3.5.2.dist-info}/METADATA +3 -3
- {swh.loader.mercurial-3.5.0.dist-info → swh.loader.mercurial-3.5.2.dist-info}/RECORD +10 -10
- {swh.loader.mercurial-3.5.0.dist-info → swh.loader.mercurial-3.5.2.dist-info}/AUTHORS +0 -0
- {swh.loader.mercurial-3.5.0.dist-info → swh.loader.mercurial-3.5.2.dist-info}/LICENSE +0 -0
- {swh.loader.mercurial-3.5.0.dist-info → swh.loader.mercurial-3.5.2.dist-info}/WHEEL +0 -0
- {swh.loader.mercurial-3.5.0.dist-info → swh.loader.mercurial-3.5.2.dist-info}/entry_points.txt +0 -0
- {swh.loader.mercurial-3.5.0.dist-info → swh.loader.mercurial-3.5.2.dist-info}/top_level.txt +0 -0
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
# License: GNU General Public License version 3, or any later version
|
|
4
4
|
# See top-level LICENSE file for more information
|
|
5
5
|
|
|
6
|
+
from datetime import datetime
|
|
6
7
|
from os.path import basename
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
import tempfile
|
|
9
|
-
from typing import Iterator
|
|
10
|
+
from typing import Any, Iterable, Iterator
|
|
10
11
|
|
|
11
12
|
from swh.loader.core.loader import BaseDirectoryLoader
|
|
12
13
|
from swh.loader.mercurial.hgutil import clone
|
|
13
14
|
from swh.loader.mercurial.utils import raise_not_found_repository
|
|
15
|
+
from swh.model.from_disk import ignore_empty_directories, ignore_named_directories
|
|
14
16
|
from swh.model.model import Snapshot, SnapshotBranch, TargetType
|
|
15
17
|
|
|
16
18
|
|
|
@@ -40,6 +42,13 @@ def clone_repository(repo_url: str, hg_changeset: str, target: Path) -> Path:
|
|
|
40
42
|
return local_clone_dir
|
|
41
43
|
|
|
42
44
|
|
|
45
|
+
def list_hg_tree(dirpath: bytes, dirname: bytes, entries: Iterable[Any]) -> bool:
|
|
46
|
+
"""List a mercurial tree. This ignores any repo_path/.hg/* and empty folders."""
|
|
47
|
+
return ignore_named_directories([b".hg"])(
|
|
48
|
+
dirpath, dirname, entries
|
|
49
|
+
) and ignore_empty_directories(dirpath, dirname, entries)
|
|
50
|
+
|
|
51
|
+
|
|
43
52
|
class HgCheckoutLoader(BaseDirectoryLoader):
|
|
44
53
|
"""Hg directory loader in charge of ingesting a mercurial tree at a specific
|
|
45
54
|
changeset, tag or branch into the swh archive.
|
|
@@ -63,10 +72,12 @@ class HgCheckoutLoader(BaseDirectoryLoader):
|
|
|
63
72
|
|
|
64
73
|
def __init__(self, *args, **kwargs):
|
|
65
74
|
self.hg_changeset = kwargs.pop("ref")
|
|
66
|
-
super().__init__(*args, **kwargs)
|
|
75
|
+
super().__init__(*args, dir_filter=list_hg_tree, **kwargs)
|
|
67
76
|
|
|
68
77
|
def fetch_artifact(self) -> Iterator[Path]:
|
|
69
|
-
with tempfile.TemporaryDirectory(
|
|
78
|
+
with tempfile.TemporaryDirectory(
|
|
79
|
+
suffix="-" + datetime.now().isoformat()
|
|
80
|
+
) as tmpdir:
|
|
70
81
|
repo = clone_repository(
|
|
71
82
|
self.origin.url, self.hg_changeset, target=Path(tmpdir)
|
|
72
83
|
)
|
swh/loader/mercurial/hgutil.py
CHANGED
|
@@ -126,7 +126,7 @@ def clone(src: str, dest: str, timeout: float = 7200, rev: Optional[str] = None)
|
|
|
126
126
|
peeropts={},
|
|
127
127
|
source=src.encode(),
|
|
128
128
|
dest=dest.encode(),
|
|
129
|
-
update=
|
|
129
|
+
update=True,
|
|
130
130
|
revs=None if not rev else [rev.encode()],
|
|
131
131
|
)
|
|
132
132
|
clone_with_timeout(src, dest, closure, timeout)
|
|
@@ -14,7 +14,7 @@ from swh.loader.mercurial.directory import HgCheckoutLoader, clone_repository
|
|
|
14
14
|
from swh.loader.mercurial.hgutil import repository
|
|
15
15
|
from swh.loader.tests import (
|
|
16
16
|
assert_last_visit_matches,
|
|
17
|
-
|
|
17
|
+
fetch_extids_from_checksums,
|
|
18
18
|
get_stats,
|
|
19
19
|
prepare_repository_from_archive,
|
|
20
20
|
)
|
|
@@ -77,14 +77,19 @@ def test_clone_repository_notfound(tmp_path):
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
@pytest.mark.parametrize(
|
|
80
|
-
"reference",
|
|
80
|
+
"reference,expected_nar_checksum",
|
|
81
81
|
[
|
|
82
|
-
"default",
|
|
83
|
-
"0.1",
|
|
84
|
-
|
|
82
|
+
("default", "e14330e8cc00a1ec3d4b0aac7dd64a27315ab8f89aacbf8c48dff412859a9e99"),
|
|
83
|
+
("0.1", "e7aae74512b72ea6e6c2f5a3de4660fff0d993ed6a690141a3164aace80f4a0d"),
|
|
84
|
+
(
|
|
85
|
+
"0a04b987be5ae354b710cefeba0e2d9de7ad41a9",
|
|
86
|
+
"8be8c3e290bd3467a352d7afb9f43c9bb6f0c1d8445c0383e7e668af5e717ad4",
|
|
87
|
+
),
|
|
85
88
|
],
|
|
86
89
|
)
|
|
87
|
-
def test_hg_directory_loader(
|
|
90
|
+
def test_hg_directory_loader(
|
|
91
|
+
swh_storage, datadir, tmp_path, reference, expected_nar_checksum
|
|
92
|
+
):
|
|
88
93
|
"""Loading a hg directory should be eventful"""
|
|
89
94
|
archive_name = "hello"
|
|
90
95
|
archive_path = os.path.join(datadir, f"{archive_name}.tgz")
|
|
@@ -93,8 +98,7 @@ def test_hg_directory_loader(swh_storage, datadir, tmp_path, reference):
|
|
|
93
98
|
)
|
|
94
99
|
|
|
95
100
|
hash_algo = "sha256"
|
|
96
|
-
|
|
97
|
-
checksums = {hash_algo: nar_ref}
|
|
101
|
+
checksums = {hash_algo: expected_nar_checksum}
|
|
98
102
|
loader = HgCheckoutLoader(
|
|
99
103
|
swh_storage,
|
|
100
104
|
repo_url,
|
|
@@ -121,13 +125,23 @@ def test_hg_directory_loader(swh_storage, datadir, tmp_path, reference):
|
|
|
121
125
|
assert set(branches) == {b"HEAD", reference.encode()}
|
|
122
126
|
|
|
123
127
|
# Ensure the extids got stored as well
|
|
124
|
-
extids =
|
|
128
|
+
extids = fetch_extids_from_checksums(
|
|
129
|
+
loader.storage,
|
|
130
|
+
checksum_layout="nar",
|
|
131
|
+
checksums=checksums,
|
|
132
|
+
extid_version=loader.extid_version,
|
|
133
|
+
)
|
|
125
134
|
|
|
126
135
|
assert len(extids) == len(checksums)
|
|
127
136
|
for extid in extids:
|
|
128
|
-
assert extid.extid_type == f"nar-{hash_algo}
|
|
129
|
-
assert extid.extid_version ==
|
|
137
|
+
assert extid.extid_type == f"nar-{hash_algo}"
|
|
138
|
+
assert extid.extid_version == loader.extid_version
|
|
130
139
|
assert extid.extid == hash_to_bytes(checksums[hash_algo])
|
|
140
|
+
assert ".hg" not in [
|
|
141
|
+
entry["name"]
|
|
142
|
+
for entry in swh_storage.directory_ls(extid.target.object_id)
|
|
143
|
+
if entry["type"] == "dir"
|
|
144
|
+
]
|
|
131
145
|
|
|
132
146
|
|
|
133
147
|
def test_hg_directory_loader_hash_mismatch(swh_storage, datadir, tmp_path):
|
|
@@ -172,7 +186,12 @@ def test_hg_directory_loader_hash_mismatch(swh_storage, datadir, tmp_path):
|
|
|
172
186
|
}
|
|
173
187
|
|
|
174
188
|
# Ensure no extids got stored
|
|
175
|
-
extids =
|
|
189
|
+
extids = fetch_extids_from_checksums(
|
|
190
|
+
loader.storage,
|
|
191
|
+
checksum_layout="nar",
|
|
192
|
+
checksums=faulty_checksums,
|
|
193
|
+
extid_version=loader.extid_version,
|
|
194
|
+
)
|
|
176
195
|
assert extids == []
|
|
177
196
|
|
|
178
197
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: swh.loader.mercurial
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.2
|
|
4
4
|
Summary: Software Heritage Mercurial Loader
|
|
5
5
|
Author-email: Software Heritage developers <swh-devel@inria.fr>
|
|
6
6
|
Project-URL: Homepage, https://gitlab.softwareheritage.org/swh/devel/swh-loader-mercurial
|
|
@@ -25,7 +25,7 @@ Requires-Dist: mercurial
|
|
|
25
25
|
Requires-Dist: swh.model >=2.6.1
|
|
26
26
|
Requires-Dist: swh.storage >=0.37.0
|
|
27
27
|
Requires-Dist: swh.scheduler >=0.0.39
|
|
28
|
-
Requires-Dist: swh.loader.core >=5.
|
|
28
|
+
Requires-Dist: swh.loader.core >=5.14.2
|
|
29
29
|
Provides-Extra: testing
|
|
30
30
|
Requires-Dist: click ; extra == 'testing'
|
|
31
31
|
Requires-Dist: patool ; extra == 'testing'
|
|
@@ -35,7 +35,7 @@ Requires-Dist: mercurial ; extra == 'testing'
|
|
|
35
35
|
Requires-Dist: swh.model >=2.6.1 ; extra == 'testing'
|
|
36
36
|
Requires-Dist: swh.storage >=0.37.0 ; extra == 'testing'
|
|
37
37
|
Requires-Dist: swh.scheduler >=0.0.39 ; extra == 'testing'
|
|
38
|
-
Requires-Dist: swh.loader.core >=5.
|
|
38
|
+
Requires-Dist: swh.loader.core >=5.14.2 ; extra == 'testing'
|
|
39
39
|
Requires-Dist: pytest ; extra == 'testing'
|
|
40
40
|
Requires-Dist: pytest-mock ; extra == 'testing'
|
|
41
41
|
Requires-Dist: swh.core[http] >=0.0.61 ; extra == 'testing'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
swh/loader/mercurial/__init__.py,sha256=ioPrVqbM_-w8sEwWUKEw9jCTbzQTkWwMaJM77D7YItM,745
|
|
2
2
|
swh/loader/mercurial/archive_extract.py,sha256=gMSxvwIxZu5-Ei9a7ZeNCjZV-wBMIBTGonUutZ16yhE,1981
|
|
3
3
|
swh/loader/mercurial/converters.py,sha256=qrL63I-6ezmICJa7cTB_jlS0kiPfHGL3xH8NXJTF1nU,1040
|
|
4
|
-
swh/loader/mercurial/directory.py,sha256=
|
|
5
|
-
swh/loader/mercurial/hgutil.py,sha256=
|
|
4
|
+
swh/loader/mercurial/directory.py,sha256=uReb_gSxRNKn79NCYpv5c8qvrzUM9iNEN6vmT1qT2us,3331
|
|
5
|
+
swh/loader/mercurial/hgutil.py,sha256=tg-QX2jRod9kUZ-nGPv30Km11Z1hTf4zINYL1T7eakk,5142
|
|
6
6
|
swh/loader/mercurial/identify.py,sha256=s6soJVvPpSwePYNRj3_Eo9WmVJvgM1XT2-xfep7pyjE,16613
|
|
7
7
|
swh/loader/mercurial/loader.py,sha256=fi3gaWFVTkbc9nslgPv7JNoUYM-xEClIHL__m45bCyg,29492
|
|
8
8
|
swh/loader/mercurial/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
|
|
@@ -12,7 +12,7 @@ swh/loader/mercurial/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
|
12
12
|
swh/loader/mercurial/tests/conftest.py,sha256=xMFVE0tp9bbspeywcIpS5gDjeZF_SMWcIgvyrsybuXQ,1671
|
|
13
13
|
swh/loader/mercurial/tests/loader_checker.py,sha256=lcOoO4viwqfUgKKm9sUBhw5_uyS93pyT-BMWDnPxgzU,2353
|
|
14
14
|
swh/loader/mercurial/tests/test_converters.py,sha256=5r02CYtZ85xdK00wcfDjmWJo1Qr4BHOYHtjxWaHOVhY,2155
|
|
15
|
-
swh/loader/mercurial/tests/test_directory.py,sha256=
|
|
15
|
+
swh/loader/mercurial/tests/test_directory.py,sha256=3BPLz6PoYH-_xf8qyMibNdXyTti3D2sDMoUTMYupsY0,6865
|
|
16
16
|
swh/loader/mercurial/tests/test_identify.py,sha256=Dp21Ic8b8HMt3hcdqHzPuTpInTk4WLD-yjf7u79PJZM,3016
|
|
17
17
|
swh/loader/mercurial/tests/test_loader.py,sha256=hoqe_mw-toRTl0Y6hU9f15TnZ8XEpCDPifeg_PT_hl4,26197
|
|
18
18
|
swh/loader/mercurial/tests/test_tasks.py,sha256=7vB4HSlmN7QKyA4p7ZnKRCmb4PgsY0qnW96KUJVjuzs,1970
|
|
@@ -33,10 +33,10 @@ swh/loader/mercurial/tests/data/the-sandbox.json,sha256=baIwB2DbiXkwzxoA0Z8vDFlt
|
|
|
33
33
|
swh/loader/mercurial/tests/data/the-sandbox.tgz,sha256=MkJ6Nx_CDRkFlox9dcfq-I2ktFa2niAeAT2f7ClvrtY,13309
|
|
34
34
|
swh/loader/mercurial/tests/data/transplant.json,sha256=h9akY1VS5nv5LOoiZuiJ3tg9ikkeciqdpjpeyGFR_p0,633
|
|
35
35
|
swh/loader/mercurial/tests/data/transplant.tgz,sha256=eoS3hnKcIOkNrx3pj8lj3lMP7_V8EEjg4rmNI0qO1Vs,3206
|
|
36
|
-
swh.loader.mercurial-3.5.
|
|
37
|
-
swh.loader.mercurial-3.5.
|
|
38
|
-
swh.loader.mercurial-3.5.
|
|
39
|
-
swh.loader.mercurial-3.5.
|
|
40
|
-
swh.loader.mercurial-3.5.
|
|
41
|
-
swh.loader.mercurial-3.5.
|
|
42
|
-
swh.loader.mercurial-3.5.
|
|
36
|
+
swh.loader.mercurial-3.5.2.dist-info/AUTHORS,sha256=CfkR1t8Z3y1NSRjmzMBmWzN55CEqCDCIXp1XtqzAjf4,117
|
|
37
|
+
swh.loader.mercurial-3.5.2.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
|
38
|
+
swh.loader.mercurial-3.5.2.dist-info/METADATA,sha256=NyMzLFFajZhAc35N0GLxyUHAEwBLjoS9ASJ0FOS_o54,3072
|
|
39
|
+
swh.loader.mercurial-3.5.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
40
|
+
swh.loader.mercurial-3.5.2.dist-info/entry_points.txt,sha256=KR1-Noi4WbxrdetuNh-QSOSVVp12_NT04aa5nK3YO5o,202
|
|
41
|
+
swh.loader.mercurial-3.5.2.dist-info/top_level.txt,sha256=8XlamXOHbQHPR7Tn7kZa8F4ufiLuK-BL_bZje5MY9hw,4
|
|
42
|
+
swh.loader.mercurial-3.5.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{swh.loader.mercurial-3.5.0.dist-info → swh.loader.mercurial-3.5.2.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|