Skip to content

Commit

Permalink
Track updated files. Close iterative#61
Browse files Browse the repository at this point in the history
  • Loading branch information
dmpetrov committed May 10, 2017
1 parent e896030 commit 0a92f93
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 1 addition & 2 deletions dvc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from dvc.runtime import Runtime
from dvc.command.init import CmdInit
from dvc.command.import_bulk import CmdImportBulk
from dvc.command.remove import CmdDataRemove
from dvc.command.run import CmdRun
from dvc.command.repro import CmdRepro
Expand All @@ -19,7 +18,7 @@
from dvc.command.lock import CmdLock
from dvc.command.test import CmdTest

VERSION = '0.8.2'
VERSION = '0.8.3'

def print_usage():
usage = ('',
Expand Down
27 changes: 26 additions & 1 deletion dvc/repository_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,32 @@ class RepositoryChange(object):
def __init__(self, cmd_args, settings, stdout, stderr, shell=False):
self._settings = settings

stemps_before = self.data_file_timesteps()

Logger.debug(u'[Repository change] Exec command: {}. stdout={}, stderr={}, shell={}'.format(
u' '.join(cmd_args),
stdout,
stderr,
shell))
Executor.exec_cmd_only_success(cmd_args, stdout, stderr, shell=shell)

stemps_after = self.data_file_timesteps()

sym_diff = stemps_after ^ stemps_before
self._modified_content_filenames = set([filename for filename, timestemp in sym_diff])

Logger.debug(u'[Repository change] Identified modifications: {}'.format(
u', '.join(self._modified_content_filenames)))

self._stated_data_items = []
self._externally_created_files = []
self._created_status_files = []
self._init_file_states()

@property
def modified_content_data_items(self):
return [self._settings.path_factory.data_item(file) for file in self._modified_content_filenames]

@cached_property
def removed_data_items(self):
return [x for x in self._stated_data_items if x.is_removed]
Expand All @@ -50,7 +64,8 @@ def unusual_data_items(self):

@property
def changed_data_items(self):
return self.new_data_items + self.modified_data_items
res = set(self.new_data_items + self.modified_data_items + self.modified_content_data_items)
return list(res)

def _add_stated_data_item(self, state, file):
try:
Expand Down Expand Up @@ -98,3 +113,13 @@ def externally_created_files(self):
@property
def created_status_files(self):
return self._created_status_files

def data_file_timesteps(self):
res = set()
for root, dirs, files in os.walk(self._settings.config.data_dir):
for file in files:
filename = os.path.join(root, file)
timestemp = os.path.getmtime(filename)
res.add((filename, timestemp))

return res

0 comments on commit 0a92f93

Please sign in to comment.