# HG changeset patch # User Jeff Hammel # Date 1381511987 25200 # Node ID 3edb91cfd3c11b8230eaef681c0c3d22d7f01a84 # Parent 4c53f4cc6ffe74c50b375e2f5864b07965999a9d move to ABC diff -r 4c53f4cc6ffe -r 3edb91cfd3c1 commitwatcher/store.py --- a/commitwatcher/store.py Wed Oct 09 14:50:07 2013 -0700 +++ b/commitwatcher/store.py Fri Oct 11 10:19:47 2013 -0700 @@ -37,6 +37,17 @@ path.pop() return paths + def paths(self, *commits): + """ + return paths touched by commits + """ + + paths = set() + for commit in commits: + for f in commit.files: + paths.update(self.ancestry(f)) + return paths + class MemoryStore(CommitStore): """store in volatile memory""" @@ -46,18 +57,9 @@ self.path_to_commit = {} self._commits = [] - def add(self, commit): + def store(self, commit): + paths = self.paths(commit) + for path in paths: + self.path_to_commit.set_default(path, []).append(commit) raise NotImplementedError() - def paths(self, *commits): - """ - return paths touched by commits - """ - - paths = set() - for commit in commits: - for f in commit.files: - for path in self.ancestry(f): - self.path_to_commit.set_default(path, []).append(commit) - # TODO: worry about commit order -