Mercurial > hg > CommitWatcher
annotate commitwatcher/store.py @ 20:a8e21cfda5fe
wip
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 29 Sep 2013 20:23:51 -0700 |
parents | 883c88b13142 |
children | be7090ee7738 |
rev | line source |
---|---|
2
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 from abc import abstractmethod |
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 |
6
883c88b13142
commitwatcher/agent.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
3 __all__ = ['CommitStore', 'MemoryStore'] |
883c88b13142
commitwatcher/agent.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
4 |
2
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 class CommitStore(object): |
5 | 6 """ |
7 ABC for commits | |
8 """ | |
2
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 |
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 @abstractmethod |
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 def add(self, commit): |
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 """adds a commit to the store""" |
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 |
5 | 14 @abstractmethod |
15 def paths(self, *commits): | |
16 """return all paths touched for a given commit""" | |
17 | |
20 | 18 def ancestry(self, path): |
19 sep = '/' # unix/url-style separators | |
20 path = path.split('/') | |
21 paths = [] | |
22 while path: | |
23 paths.append(sep.join(path)) | |
24 path.pop() | |
25 return paths | |
26 | |
5 | 27 |
2
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
28 class MemoryStore(CommitStore): |
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
29 """store in volatile memory""" |
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
30 # volatile! |
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
31 |
20 | 32 def __init__(self): |
33 self.path_to_commit = {} | |
34 | |
2
4cb3971d9d9d
commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
35 def add(self, commit): |
5 | 36 raise NotImplementedError() |
37 | |
38 def paths(self, *commits): | |
39 """ | |
40 return touched by commits | |
41 """ | |
20 | 42 |
43 paths = set() | |
44 for commit in commits: | |
45 for f in commit.files: | |
46 | |
47 raise NotImplementedError |