Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/replay.py
Show First 20 Lines • Show All 658 Lines • ▼ Show 20 Lines | ) -> None: | ||||
# be versioned and must be overridden only if the external URL is | # be versioned and must be overridden only if the external URL is | ||||
# still valid | # still valid | ||||
temp_dir = os.fsencode( | temp_dir = os.fsencode( | ||||
tempfile.mkdtemp(dir=self.editor.externals_cache_dir) | tempfile.mkdtemp(dir=self.editor.externals_cache_dir) | ||||
) | ) | ||||
temp_path = os.path.join(temp_dir, dest_path) | temp_path = os.path.join(temp_dir, dest_path) | ||||
os.makedirs(b"/".join(temp_path.split(b"/")[:-1]), exist_ok=True) | os.makedirs(b"/".join(temp_path.split(b"/")[:-1]), exist_ok=True) | ||||
if external_url not in self.editor.dead_externals: | if external_url not in self.editor.dead_externals: | ||||
logger.debug("Exporting external %s to path %s", external_url, path) | logger.debug( | ||||
"Exporting external %s%s to path %s", | |||||
external_url, | |||||
f"@{revision}" if revision else "", | |||||
vlorentz: Looks like a false positive if `external_url` is "https://example.org/foo/" and `self.svnrepo. | |||||
Done Inline Actionsah right, I must add the trailing slash when checking prefix in that case, thanks anlambert: ah right, I must add the trailing slash when checking prefix in that case, thanks | |||||
Not Done Inline Actionscould you add a regression test for this? vlorentz: could you add a regression test for this? | |||||
Done Inline ActionsI will try, I should be able to test the exported URL by mocking the svnrepo.client object. anlambert: I will try, I should be able to test the exported URL by mocking the `svnrepo.client` object. | |||||
Done Inline ActionsI managed to write a test checking export URLs are the expected ones. anlambert: I managed to write a test checking export URLs are the expected ones. | |||||
path, | |||||
) | |||||
url = external_url.rstrip("/") | |||||
origin_url = self.svnrepo.origin_url.rstrip("/") | |||||
if ( | |||||
url.startswith(origin_url + "/") | |||||
and not self.svnrepo.has_relative_externals | |||||
): | |||||
url = url.replace(origin_url, self.svnrepo.remote_url) | |||||
logger.debug( | |||||
"svn export --ignore-keywords %s%s", | |||||
url, | |||||
f"@{revision}" if revision else "", | |||||
) | |||||
self.svnrepo.client.export( | self.svnrepo.client.export( | ||||
external_url.rstrip("/"), | url, to=temp_path, peg_rev=revision, ignore_keywords=True, | ||||
to=temp_path, | |||||
peg_rev=revision, | |||||
ignore_keywords=True, | |||||
) | ) | ||||
self.editor.externals_cache[external] = temp_path | self.editor.externals_cache[external] = temp_path | ||||
except SubversionException as se: | except SubversionException as se: | ||||
# external no longer available (404) | # external no longer available (404) | ||||
logger.debug(se) | logger.debug(se) | ||||
self.editor.dead_externals.add(external_url) | self.editor.dead_externals.add(external_url) | ||||
▲ Show 20 Lines • Show All 320 Lines • Show Last 20 Lines |
Looks like a false positive if external_url is "https://example.org/foo/" and self.svnrepo.origin_url is "https://example.org/foobar/"