Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/utils.py
Show First 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | if "@" in external_url: | ||||
# ensure revision_s can be parsed to int | # ensure revision_s can be parsed to int | ||||
rev = int(revision_s) | rev = int(revision_s) | ||||
# -r XXX takes priority over <svn_url>@XXX | # -r XXX takes priority over <svn_url>@XXX | ||||
revision = revision or rev | revision = revision or rev | ||||
external_url = url | external_url = url | ||||
except ValueError: | except ValueError: | ||||
# handle URL like http://user@svn.example.org/ | # handle URL like http://user@svn.example.org/ | ||||
pass | pass | ||||
if not external_url or not path: | |||||
vlorentz: as failures probably have weird characters in them | |||||
raise ValueError(f"Failed to parse external definition '{external}'") | |||||
return (path.rstrip("/"), external_url, revision, relative_url) | return (path.rstrip("/"), external_url, revision, relative_url) | ||||
def is_recursive_external( | def is_recursive_external( | ||||
origin_url: str, dir_path: str, external_path: str, external_url: str | origin_url: str, dir_path: str, external_path: str, external_url: str | ||||
) -> bool: | ) -> bool: | ||||
""" | """ | ||||
Check if an external definition can lead to a recursive subversion export | Check if an external definition can lead to a recursive subversion export | ||||
operation (https://issues.apache.org/jira/browse/SVN-1703). | operation (https://issues.apache.org/jira/browse/SVN-1703). | ||||
Args: | Args: | ||||
origin_url: repository URL | origin_url: repository URL | ||||
dir_path: path of the directory where external is defined | dir_path: path of the directory where external is defined | ||||
external_path: path of the external relative to the directory | external_path: path of the external relative to the directory | ||||
external_url: external URL | external_url: external URL | ||||
Returns: | Returns: | ||||
Whether the external definition is recursive | Whether the external definition is recursive | ||||
""" | """ | ||||
assert external_url | |||||
parsed_origin_url = urlparse(origin_url) | parsed_origin_url = urlparse(origin_url) | ||||
parsed_external_url = urlparse(external_url) | parsed_external_url = urlparse(external_url) | ||||
external_url = urlunparse( | external_url = urlunparse( | ||||
parsed_external_url._replace(scheme=parsed_origin_url.scheme) | parsed_external_url._replace(scheme=parsed_origin_url.scheme) | ||||
) | ) | ||||
return svn_urljoin(origin_url, quote(dir_path), quote(external_path)).startswith( | return svn_urljoin(origin_url, quote(dir_path), quote(external_path)).startswith( | ||||
external_url | external_url | ||||
) | ) |
as failures probably have weird characters in them