diff --git a/dvc/repo/scm_context.py b/dvc/repo/scm_context.py index b5985b117..c0b0ffb5b 100644 --- a/dvc/repo/scm_context.py +++ b/dvc/repo/scm_context.py @@ -4,6 +4,7 @@ def scm_context(method): result = method(repo, *args, **kw) repo.scm.reset_ignores() repo.scm.remind_to_track() + repo.scm.reset_tracked_files() return result except Exception: repo.scm.cleanup_ignores() diff --git a/dvc/scm/base.py b/dvc/scm/base.py index d7f5333e3..e52fafe99 100644 --- a/dvc/scm/base.py +++ b/dvc/scm/base.py @@ -126,6 +126,11 @@ class Base(object): Method to reset in-memory ignore storing mechanism. """ + def reset_tracked_files(self): + """ + Method to reset in-memory tracked files storing mechanism. + """ + def remind_to_track(self): """ Method to remind user to track newly created files handled by scm diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 339e64339..c0592e896 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -54,7 +54,7 @@ class Git(Base): self.git.git.update_environment(LD_LIBRARY_PATH=libpath) self.ignored_paths = [] - self.files_to_track = [] + self.files_to_track = set() @staticmethod def is_repo(root_dir): @@ -245,6 +245,9 @@ class Git(Base): def reset_ignores(self): self.ignored_paths = [] + def reset_tracked_files(self): + self.files_to_track = set() + def remind_to_track(self): if not self.files_to_track: return @@ -257,7 +260,7 @@ class Git(Base): ) def track_file(self, path): - self.files_to_track.append(path) + self.files_to_track.add(path) def belongs_to_scm(self, path): basename = os.path.basename(path)