repo: add get_data_index_entry to handle subrepo lookup

This commit is contained in:
Peter Rowlands
2023-07-12 14:45:11 +09:00
committed by Peter Rowlands (변기호)
parent f69b3533e4
commit dd4035bc05
3 changed files with 32 additions and 19 deletions
+7 -16
View File
@@ -45,22 +45,13 @@ def get_url(path, repo=None, rev=None, remote=None):
with Repo.open(
repo, rev=rev, subrepos=True, uninitialized=True, **repo_kwargs
) as _repo:
with _wrap_exceptions(_repo, path):
fs_path = _repo.dvcfs.from_os_path(path)
fs = _repo.dvcfs.fs
# pylint: disable-next=protected-access
key = fs._get_key_from_relative(fs_path)
# pylint: disable-next=protected-access
subrepo, _, subkey = fs._get_subrepo_info(key)
index = subrepo.index.data["repo"]
with reraise(KeyError, OutputNotFoundError(path, repo)):
entry = index[subkey]
with reraise(
(StorageKeyError, ValueError),
NoRemoteError(f"no remote specified in {_repo}"),
):
remote_fs, remote_path = index.storage_map.get_remote(entry)
return remote_fs.unstrip_protocol(remote_path)
index, entry = _repo.get_data_index_entry(path)
with reraise(
(StorageKeyError, ValueError),
NoRemoteError(f"no remote specified in {_repo}"),
):
remote_fs, remote_path = index.storage_map.get_remote(entry)
return remote_fs.unstrip_protocol(remote_path)
class _OpenContextManager(GCM):