Mercurial > hg > CommitWatcher
annotate commitwatcher/agent.py @ 10:7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 28 Sep 2013 05:10:14 -0700 |
parents | 08dd6fbbec3a |
children | 546695da018c |
rev | line source |
---|---|
1 | 1 """ |
2 agents to gather commits | |
3 """ | |
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:
1
diff
changeset
|
5 import feedparser |
10
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
6 from abc import abstractmethod |
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:
1
diff
changeset
|
7 from .commit import Commit |
6
883c88b13142
commitwatcher/agent.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
2
diff
changeset
|
8 from .store import MemoryStore |
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:
1
diff
changeset
|
9 |
1 | 10 class Agent(object): |
11 """abstract base class""" | |
12 | |
6
883c88b13142
commitwatcher/agent.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
2
diff
changeset
|
13 def __init__(self, repository, store=None): |
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:
1
diff
changeset
|
14 """ |
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:
1
diff
changeset
|
15 repository -- repo to monitor |
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:
1
diff
changeset
|
16 """ |
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:
1
diff
changeset
|
17 self.repository = repository |
6
883c88b13142
commitwatcher/agent.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents:
2
diff
changeset
|
18 self.store = MemoryStore() if store is None else store |
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:
1
diff
changeset
|
19 |
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:
1
diff
changeset
|
20 |
1 | 21 class LocalCheckoutAgent(object): |
22 """agent based on local checkouts""" | |
23 | |
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:
1
diff
changeset
|
24 |
1 | 25 class FeedAgent(Agent): |
26 """gathers changesets by reading RSS/Atom""" | |
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:
1
diff
changeset
|
27 |
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:
1
diff
changeset
|
28 def feed(self): |
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:
1
diff
changeset
|
29 """feed URL""" |
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:
1
diff
changeset
|
30 return '/'.join((self.repository.rstrip('/'), 'atom-log')) |
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:
1
diff
changeset
|
31 |
9 | 32 @abstractmethod |
33 def files(self, revision): | |
34 """gets the files from the revision link""" | |
35 | |
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:
1
diff
changeset
|
36 def update(self): |
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:
1
diff
changeset
|
37 """update""" |
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:
1
diff
changeset
|
38 |
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:
1
diff
changeset
|
39 feed = feedparser.parse(self.feed()) |
8 | 40 for entry in feed['entries']: |
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:
1
diff
changeset
|
41 |
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:
1
diff
changeset
|
42 link = entry['link'] |
9 | 43 files = self.files(link) |
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:
1
diff
changeset
|
44 # TODO |
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:
1
diff
changeset
|
45 |
7 | 46 # TODO commit = Commit() |
10
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
47 |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
48 class FeedAgentDiff(FeedAgent): |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
49 """read files from diff""" |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
50 |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
51 def diff_url(self, link): |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
52 """ |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
53 returns diff_url from revision link: |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
54 |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
55 >>> diff_url('http://hg.mozilla.org/mozilla-central/rev/4e1a3919e741') |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
56 'http://hg.mozilla.org/mozilla-central/raw-rev/4e1a3919e741' |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
57 """ |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
58 return '/raw-rev/'.join(link.rsplit('/rev/', 1)) |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
59 |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
60 def files(self, revision): |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
61 """ |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
62 revision -- revision link |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
63 """ |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
64 |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
65 raw_rev = self.diff_url(revision) |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
66 print raw_rev |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
67 |
7ae60d2ff1c2
commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
68 # get paths from diff |