diff --git a/dvc/command/repro.py b/dvc/command/repro.py index 44a085f06..a0e9a1122 100644 --- a/dvc/command/repro.py +++ b/dvc/command/repro.py @@ -31,7 +31,6 @@ class CmdRepro(CmdRun): parser.add_argument('target', metavar='', help='Data item to reproduce', nargs='*') pass - @property def is_reproducible(self): return True @@ -78,7 +77,8 @@ class CmdRepro(CmdRun): for data_item in data_item_list: try: - repro_change = ReproChange(data_item, self) + target_commit = self.git.get_target_commit(data_item.data.relative) + repro_change = ReproChange(data_item, self, target_commit) if repro_change.reproduce(): changed = True Logger.info(u'Data item "{}" was reproduced.'.format( @@ -103,7 +103,7 @@ class CmdRepro(CmdRun): class ReproChange(object): - def __init__(self, data_item, cmd_obj): + def __init__(self, data_item, cmd_obj, target_commit): self._data_item = data_item self.git = cmd_obj.git self._cmd_obj = cmd_obj @@ -111,6 +111,8 @@ class ReproChange(object): cmd_obj._code = self.state.code_dependencies + self._target_commit = target_commit + argv = self.state.norm_argv if not argv: @@ -156,13 +158,13 @@ class ReproChange(object): were_input_files_changed = False for data_item in self.dependencies: - change = ReproChange(data_item, self._cmd_obj) + change = ReproChange(data_item, self._cmd_obj, self._target_commit) if change.reproduce(force): were_input_files_changed = True - was_source_code_changed = self.git.were_files_changed(self._data_item.data.relative, - self.state.code_dependencies + self.state.input_files, - self.cmd_obj.settings.path_factory) + was_source_code_changed = self.git.were_files_changed(self.state.code_dependencies + self.state.input_files, + self.cmd_obj.settings.path_factory, + self._target_commit) if was_source_code_changed: Logger.debug('Dependencies were changed for "{}"'.format(self._data_item.data.dvc)) diff --git a/dvc/git_wrapper.py b/dvc/git_wrapper.py index 85b72d516..005cbfa96 100644 --- a/dvc/git_wrapper.py +++ b/dvc/git_wrapper.py @@ -157,18 +157,15 @@ class GitWrapper(GitWrapperI): return results - def were_files_changed(self, file, code_dependencies, path_factory): - Logger.debug('[Git] Identify changes. Commands: {} {} && {}'.format( - 'git log -1 --pretty=format:"%h"', file, 'git diff --name-only HEAD *')) + def were_files_changed(self, code_dependencies, path_factory, target_commit): + Logger.debug('[Git] Identify changes. Command: git diff --name-only HEAD {}'.format( + target_commit)) - commit = Executor.exec_cmd_only_success(['git', 'log', '-1', '--pretty=format:"%h"', file]) - commit = commit.strip('"') - - changed_files = Executor.exec_cmd_only_success(['git', 'diff', '--name-only', 'HEAD', commit]) + changed_files = Executor.exec_cmd_only_success(['git', 'diff', '--name-only', 'HEAD', target_commit]) changed_files = changed_files.strip('"') Logger.debug('[Git] Identify changes. Success. Changed files: {}'.format( - changed_files.replace('\n', ', '))) + changed_files.replace('\n', ', '))) code_files, code_dirs = self.separate_dependency_files_and_dirs(code_dependencies) code_files_set = set([path_factory.path(x).dvc for x in code_files]) @@ -182,6 +179,11 @@ class GitWrapper(GitWrapperI): return False + @staticmethod + def get_target_commit(file): + commit = Executor.exec_cmd_only_success(['git', 'log', '-1', '--pretty=format:"%h"', file]) + return commit.strip('"') + def separate_dependency_files_and_dirs(self, code_dependencies): code_files = [] code_dirs = [] diff --git a/dvc/runtime.py b/dvc/runtime.py index b3a0a0a40..8b52df148 100644 --- a/dvc/runtime.py +++ b/dvc/runtime.py @@ -12,11 +12,6 @@ from dvc.system import System class Runtime(object): CONFIG = 'dvc.conf' - @staticmethod - def symlink_setup(): - if os.name != 'nt': - return - @staticmethod def conf_file_path(git_dir): return System.realpath(os.path.join(git_dir, Runtime.CONFIG)) @@ -30,7 +25,6 @@ class Runtime(object): """ try: - Runtime.symlink_setup() runtime_git = GitWrapper() if parse_config: