Skip to content

Commit

Permalink
dvc: get rid of is_walking_tree
Browse files Browse the repository at this point in the history
No longer needed. Some applications of `isinstance()` will be refactored
in the future, as trees will just provide the needed functionality.
  • Loading branch information
efiop committed Jul 19, 2020
1 parent 7b1823e commit e55f4a0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
6 changes: 2 additions & 4 deletions dvc/external_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from dvc.repo import Repo
from dvc.repo.tree import RepoTree
from dvc.scm.git import Git
from dvc.scm.tree import is_working_tree
from dvc.tree.local import LocalRemoteTree
from dvc.utils.fs import remove

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -102,10 +102,8 @@ def repo_tree(self):
return RepoTree(self, fetch=True)

def get_rev(self):
if is_working_tree(self.tree):
if isinstance(self.tree, LocalRemoteTree):
return self.scm.get_rev()
if hasattr(self.tree, "tree"):
return self.tree.tree.rev
return self.tree.rev

def fetch_external(self, paths: Iterable, **kwargs):
Expand Down
7 changes: 5 additions & 2 deletions dvc/output/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from dvc.exceptions import DvcException
from dvc.istextfile import istextfile
from dvc.output.base import BaseOutput
from dvc.scm.tree import is_working_tree
from dvc.utils import relpath
from dvc.utils.fs import path_isin

Expand All @@ -23,7 +22,11 @@ def __init__(self, stage, path, *args, **kwargs):
path = relpath(path, stage.wdir)

super().__init__(stage, path, *args, **kwargs)
if self.is_in_repo and self.repo and is_working_tree(self.repo.tree):
if (
self.is_in_repo
and self.repo
and isinstance(self.repo.tree, LocalRemoteTree)
):
self.tree = self.repo.tree

def _parse_path(self, tree, path):
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/diff.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from dvc.repo import locked
from dvc.scm.tree import is_working_tree
from dvc.tree.local import LocalRemoteTree


@locked
Expand Down Expand Up @@ -33,7 +33,7 @@ def _to_path(output):
else os.path.join(str(output), "")
)

on_working_tree = is_working_tree(self.tree)
on_working_tree = isinstance(self.tree, LocalRemoteTree)

def _to_checksum(output):
if on_working_tree:
Expand Down
6 changes: 0 additions & 6 deletions dvc/scm/tree.py

This file was deleted.

0 comments on commit e55f4a0

Please sign in to comment.