Skip to content
Snippets Groups Projects
Commit 651e2964 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

utils: Ensure to return correct revision in parse_external_definition

An external definition can be of the following form (where XXX and YYY
are revision numbers):

	-r XXX <repo_url>@YYY

In that case, the official subversion client will export the revision
XXX of the external repository.

So ensure to have the same behavior when the subversion loader processes
a repository with such external defintion in it.
parent 67036559
Branches debian/unstable-swh
Tags debian/2.1.0-1_swh1
1 merge request!146utils: Ensure to return correct revision in parse_external_definition
......@@ -408,6 +408,18 @@ def test_svn_urljoin(base_url, paths_to_join, expected_result):
False,
),
),
(
"-r 123 http://svn.example.com/repos/sounds@100 third-party/sounds",
"trunk/externals",
"http://svn.example.org/repos/test",
("third-party/sounds", "http://svn.example.com/repos/sounds", 123, False),
),
(
"-r 123 http://svn.example.com/repos/sounds@150 third-party/sounds",
"trunk/externals",
"http://svn.example.org/repos/test",
("third-party/sounds", "http://svn.example.com/repos/sounds", 123, False),
),
],
)
def test_parse_external_definition(external, dir_path, repo_url, expected_result):
......
......@@ -288,7 +288,10 @@ def parse_external_definition(
# http://svn.example.org/repos/test/path@XXX
url, revision_s = external_url.rsplit("@", maxsplit=1)
try:
revision = int(revision_s)
# ensure revision_s can be parsed to int
rev = int(revision_s)
# -r XXX takes priority over <svn_url>@XXX
revision = revision or rev
external_url = url
except ValueError:
# handle URL like http://user@svn.example.org/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment