From 524901d4ad78a3b5f9a819237eff550a89cee98b Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 13 Nov 2017 00:51:54 -0800 Subject: [PATCH] Bug fixing --- dvc/command/checkout.py | 5 +++-- dvc/git_wrapper.py | 6 +++--- dvc/path/factory.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dvc/command/checkout.py b/dvc/command/checkout.py index 8baa65dd3..eb51a824b 100644 --- a/dvc/command/checkout.py +++ b/dvc/command/checkout.py @@ -39,7 +39,7 @@ class CmdCheckout(CmdBase): states = self.git.state_files_for_previous_commit() prev_items = self.settings.path_factory.data_items_from_states(states, existing=False) except Exception as ex: - Logger.error(u'Unable to get data files from previous commit'.format(ex)) + Logger.error(u'Unable to get data files from previous commit: {}'.format(ex)) return 1 curr_items = self.settings.path_factory.all_existing_data_items() @@ -53,7 +53,8 @@ class CmdCheckout(CmdBase): for item in removed_items_set: path = item.data.relative if not os.path.exists(path): - print(u'Remove \'{}\' - file does not exist'.format(path)) + print(u'Remove \'{}\'.'.format(path)) + Logger.warn(u'File \'{}\' does not exist'.format(path)) else: Logger.info(u'Remove \'{}\''.format(path)) os.remove(path) diff --git a/dvc/git_wrapper.py b/dvc/git_wrapper.py index c1d27fbb9..857b77a96 100644 --- a/dvc/git_wrapper.py +++ b/dvc/git_wrapper.py @@ -4,7 +4,7 @@ from collections import defaultdict from dvc.exceptions import DvcException from dvc.logger import Logger -from dvc.config import Config +from dvc.config import Config, ConfigI from dvc.executor import Executor, ExecutorError from dvc.path.data_item import DataItemError from dvc.state_file import StateFile @@ -432,8 +432,8 @@ class GitWrapper(GitWrapperI): @staticmethod def state_files_for_previous_commit(): commit = GitWrapper.git_prev_commit() - Logger.debug(u'[dvc-git] Previous commit {}'.format(commit)) + Logger.debug(u'[dvc-git] Previous commit "{}"'.format(commit)) git_cmd = u'git ls-tree --name-only -r {}'.format(commit) lines = Executor.exec_cmd_only_success(git_cmd.split()).split('\n') - return filter(lambda s: s.startswith('.dvc/state'), map(unicode.split, lines)) + return filter(lambda s: s.startswith(ConfigI.STATE_DIR), lines) diff --git a/dvc/path/factory.py b/dvc/path/factory.py index 2f7ef5a36..4f7d8a591 100644 --- a/dvc/path/factory.py +++ b/dvc/path/factory.py @@ -73,5 +73,5 @@ class PathFactory(object): states) @staticmethod - def state_path_to_dvc_path(self, state): + def state_path_to_dvc_path(state): return os.path.relpath(state, ConfigI.STATE_DIR)[:-len(DataItem.STATE_FILE_SUFFIX)]