class Branch(object):
"""A version control branch."""
- def authors(self, limit=None):
- """Determine all authors that have contributed to this project.
- """
- ret = set()
- for rev in self.log(limit=limit):
- ret.add(rev.author)
- return ret
-
def log(self, limit=None):
raise NotImplementedError(self.log)
def diff(self, revision):
raise NotImplementedError(self.diff)
+ def changes_summary(self, revision):
+ raise NotImplementedError(self.changes_summary)
+
class Revision(object):
- def __init__(self, revision, date, committer, author, message, modified=[], added=[],
- removed=[]):
+ def __init__(self, revision, date, committer, author, message):
self.revision = revision
self.date = date
self.author = author
self.committer = committer
self.message = message
- self.modified = modified
- self.added = added
- self.removed = removed
class GitBranch(Branch):
return self.store.tree_changes(parent_tree, commit.tree)
def _revision_from_commit(self, commit):
- added = set()
- modified = set()
- removed = set()
- for ((oldpath, newpath), (oldmode, newmode), (oldsha, newsha)) in self._changes_for(commit):
- if oldpath is None:
- added.add(newpath)
- elif newpath is None:
- removed.add(oldpath)
- else:
- modified.add(newpath)
return Revision(commit.id, commit.commit_time,
committer=commit.committer, author=commit.author,
- message=commit.message, modified=modified, removed=removed,
- added=added)
+ message=commit.message)
def log(self, from_rev=None, exclude_revs=None, limit=None):
if from_rev is None:
continue
pending_commits.append(p)
+ def changes_summary(self, revision):
+ commit = self.repo[revision]
+ added = set()
+ modified = set()
+ removed = set()
+ for ((oldpath, newpath), (oldmode, newmode), (oldsha, newsha)) in self._changes_for(commit):
+ if oldpath is None:
+ added.add(newpath)
+ elif newpath is None:
+ removed.add(oldpath)
+ else:
+ modified.add(newpath)
+ return (added, modified, removed)
+
def diff(self, revision):
commit = self.repo[revision]
f = StringIO()
raise Exception("Unknown scm %s" % t.scm)
-def history_row_html(myself, entry, tree):
+def history_row_html(myself, entry, tree, changes):
"""show one row of history table"""
msg = cgi.escape(entry.message)
t = time.asctime(time.gmtime(entry.date))
myself, tree.name, entry.date, revision_url,
msg, entry.author)
- if entry.modified:
+ (added, modified, removed) = changes
+
+ if modified:
yield "<div class=\"files\"><span class=\"label\">Modified: </span>"
- yield web_paths(tree, entry.modified)
+ yield web_paths(tree, modified)
yield "</div>\n"
- if entry.added:
+ if added:
yield "<div class=\"files\"><span class=\"label\">Added: </span>"
- yield web_paths(tree, entry.added)
+ yield web_paths(tree, added)
yield "</div>\n"
- if entry.removed:
+ if removed:
yield "<div class=\"files\"><span class=\"label\">Removed: </span>"
- yield web_paths(tree, entry.removed)
+ yield web_paths(tree, removed)
yield "</div>\n"
yield "</div>\n"
-def history_row_text(entry, tree):
+def history_row_text(entry, tree, changes):
"""show one row of history table"""
msg = cgi.escape(entry.message)
t = time.asctime(time.gmtime(entry.date))
yield "Author: %s\n" % entry.author
if entry.revision:
yield "Revision: %s\n" % entry.revision
- yield "Modified: %s\n" % entry.modified
- yield "Added: %s\n" % entry.added
- yield "Removed: %s\n" % entry.removed
+ (added, modified, removed) = changes
+ yield "Modified: %s\n" % modified
+ yield "Added: %s\n" % added
+ yield "Removed: %s\n" % removed
yield "\n\n%s\n\n\n" % msg
def render(self, myself, tree, revision):
t = self.buildfarm.trees[tree]
- (entry, diff) = t.get_branch().diff(revision)
+ branch = t.get_branch()
+ (entry, diff) = branch.diff(revision)
# get information about the current diff
title = "GIT Diff in %s:%s for revision %s" % (
tree, t.branch, revision)
yield "<h2>%s</h2>" % title
- yield "".join(history_row_html(myself, entry, t))
+ changes = branch.changes_summary(revision)
+ yield "".join(history_row_html(myself, entry, t, changes))
yield show_diff(diff, "html")
class RecentCheckinsPage(BuildFarmPage):
+ limit = 40
+
def render(self, myself, tree, author=None):
t = self.buildfarm.trees[tree]
+ interesting = list()
authors = set(["ALL"])
- authors.update(t.get_branch().authors(limit=HISTORY_HORIZON))
+ branch = t.get_branch()
+ for entry in branch.log(limit=HISTORY_HORIZON):
+ authors.add(entry.author)
+ if author in ("ALL", "", entry.author):
+ interesting.append(entry)
yield "<h2>Recent checkins for %s (%s branch %s)</h2>\n" % (
tree, t.scm, t.branch)
yield "<input type='hidden' name='function', value='Recent Checkins'/>"
yield "</form>"
- branch = t.get_branch()
-
- for entry in branch.log(limit=HISTORY_HORIZON):
- if author in ("ALL", "", entry.author):
- yield "".join(history_row_html(myself, entry, t))
+ for entry in interesting[:self.limit]:
+ changes = branch.changes_summary(entry.revision)
+ yield "".join(history_row_html(myself, entry, t, changes))
yield "\n"
-
class BuildFarmApp(object):
def __init__(self, buildfarm):
start_response('200 OK', [('Content-type', 'application/x-diff')])
tree = get_param(form, 'tree')
t = self.buildfarm.trees[tree]
- (entry, diff) = t.get_branch().diff(get_param(form, 'revision'))
- yield "".join(history_row_text(entry, tree))
+ branch = t.get_branch()
+ revision = get_param(form, 'revision')
+ (entry, diff) = branch.diff(revision)
+ changes = branch.changes_summary(revision)
+ yield "".join(history_row_text(entry, tree, changes))
yield show_diff(diff, "text")
elif fn_name == 'Text_Summary':
start_response('200 OK', [('Content-type', 'text/plain')])