From 5c7627d29cb46909e347be2a3cd8ae6594224fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Fri, 6 Nov 2026 14:13:03 +0545 Subject: [PATCH] relpath: let os.path.relpath detect different drives on Windows The os.path.commonpath() guard added in a80305b also raises ValueError when one path has a root and the other does not, as with a UNC share root without a trailing separator ("\\srv\sh"). relpath() then returned the absolute path instead of a relative one. os.path.relpath() raises ValueError on Windows only when the drives differ (or the path is empty, which abspath rules out), so catch that instead. Co-Authored-By: Claude Opus 5.5 --- src/dvc_objects/fs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dvc_objects/fs/utils.py b/src/dvc_objects/fs/utils.py index e8166d3..5018e8c 100644 --- a/src/dvc_objects/fs/utils.py +++ b/src/dvc_objects/fs/utils.py @@ -54,7 +54,7 @@ def resolve_network_drive_windows(path_to_resolve): path = resolve_network_drive_windows(os.path.abspath(path)) start = resolve_network_drive_windows(start) try: - os.path.commonpath([start, path]) + return os.path.relpath(path, start) except ValueError: # paths are on different drives return path