From f661cee8f650e8eaf513aa1a929fe5cf4a4609a4 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 1 Feb 2023 05:21:53 +0200 Subject: [PATCH] stage: use repo.fs directly without copying (#8929) Otherwise when using brancher we end up in a strange situation where even though we are collecting targets from `gitfs`, we are still using `localfs` as `self.fs`, which make operations like `self.fs.abspath` in `collect_granular` return invalid paths. --- dvc/repo/stage.py | 5 ++++- tests/func/test_repo_index.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dvc/repo/stage.py b/dvc/repo/stage.py index 0f44ae76d..43d477e18 100644 --- a/dvc/repo/stage.py +++ b/dvc/repo/stage.py @@ -96,7 +96,10 @@ def locked(f): class StageLoad: def __init__(self, repo: "Repo") -> None: self.repo: "Repo" = repo - self.fs = repo.fs + + @property + def fs(self): + return self.repo.fs @locked def add( diff --git a/tests/func/test_repo_index.py b/tests/func/test_repo_index.py index 5145080f0..281e2e164 100644 --- a/tests/func/test_repo_index.py +++ b/tests/func/test_repo_index.py @@ -296,6 +296,16 @@ def test_view_combined_filter(tmp_dir, scm, dvc, run_copy): } +def test_view_brancher(tmp_dir, scm, dvc): + tmp_dir.dvc_gen({"foo": "foo"}, commit="init") + index = Index.from_repo(dvc) + + for _ in dvc.brancher(revs=["HEAD"]): + view = index.targets_view("foo") + data = view.data["repo"] + assert data[("foo",)] + + def test_with_gitignore(tmp_dir, dvc, scm): (stage,) = tmp_dir.dvc_gen({"data": {"foo": "foo", "bar": "bar"}})