mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
fspath: introduce relparts
This commit is contained in:
+1
-1
@@ -331,7 +331,7 @@ class BaseFileSystem:
|
||||
return None
|
||||
|
||||
to_infos = (
|
||||
localfs.path.join(to_info, self.path.relpath(info, from_info))
|
||||
localfs.path.join(to_info, *self.path.relparts(info, from_info))
|
||||
for info in from_infos
|
||||
)
|
||||
callback.set_size(len(from_infos))
|
||||
|
||||
@@ -77,5 +77,8 @@ class Path:
|
||||
normbase = base.rstrip(self.sep)
|
||||
return normpath[len(normbase) + 1 :]
|
||||
|
||||
def relparts(self, path, base):
|
||||
return self.parts(self.relpath(path, base))
|
||||
|
||||
def as_posix(self, path):
|
||||
return path.replace(self.sep, posixpath.sep)
|
||||
|
||||
@@ -163,8 +163,7 @@ def _build_tree(fs_path, fs, name, **kwargs):
|
||||
# Yes, this is a BUG, as long as we permit "/" in
|
||||
# filenames on Windows and "\" on Unix
|
||||
|
||||
relpath = fs.path.relpath(file_fs_path, fs_path)
|
||||
key = tuple(relpath.split(fs.path.sep))
|
||||
key = fs.path.relparts(file_fs_path, fs_path)
|
||||
assert key
|
||||
tree.add(key, meta, obj.hash_info)
|
||||
|
||||
|
||||
+1
-1
@@ -718,7 +718,7 @@ class Output:
|
||||
|
||||
fs_path = self.fs.path
|
||||
if filter_info and filter_info != self.fs_path:
|
||||
prefix = fs_path.parts(fs_path.relpath(filter_info, self.fs_path))
|
||||
prefix = fs_path.relparts(filter_info, self.fs_path)
|
||||
obj = obj.get(self.odb, prefix)
|
||||
|
||||
return obj
|
||||
|
||||
Reference in New Issue
Block a user