Rev 20: Add --show-class argument to stats command. in file:///data/jelmer/bzr-stats/trunk/
Jelmer Vernooij
jelmer at samba.org
Sat Jun 28 21:34:18 BST 2008
At file:///data/jelmer/bzr-stats/trunk/
------------------------------------------------------------
revno: 20
revision-id: jelmer at samba.org-20080628203411-ev9rbjtoe25i25ew
parent: jelmer at samba.org-20080628203101-o51yt42l6tjuclq5
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sat 2008-06-28 22:34:11 +0200
message:
Add --show-class argument to stats command.
modified:
__init__.py __init__.py-20060629132721-mkbaty0vfk4y3v59-1
=== modified file '__init__.py'
--- a/__init__.py 2008-06-28 20:31:01 +0000
+++ b/__init__.py 2008-06-28 20:34:11 +0000
@@ -163,7 +163,7 @@
return info
-def display_info(info, to_file):
+def display_info(info, to_file, gather_class_stats=None):
"""Write out the information"""
for count, revs, emails, fullnames in info:
@@ -193,6 +193,11 @@
to_file.write("''\n")
else:
to_file.write("%s\n" % (email,))
+ if gather_class_stats is not None:
+ print ' Contributions:'
+ classes, total = gather_class_stats(revs)
+ for name,count in sorted(classes.items(), lambda x,y: cmp((x[1], x[0]), (y[1], y[0]))):
+ to_file.write(" %4.0f%% %s\n" % ((float(count) / total) * 100.0, "Unknown" if name is None else name))
class cmd_committer_statistics(commands.Command):
@@ -200,11 +205,12 @@
aliases = ['stats', 'committer-stats']
takes_args = ['location?']
- takes_options = ['revision']
+ takes_options = ['revision',
+ option.Option('show-class', help="Show the class of contributions")]
encoding_type = 'replace'
- def run(self, location='.', revision=None):
+ def run(self, location='.', revision=None, show_class=False):
alternate_rev = None
try:
wt = workingtree.WorkingTree.open_containing(location)[0]
@@ -229,7 +235,9 @@
info = get_info(a_branch.repository, last_rev)
finally:
a_branch.unlock()
- display_info(info, self.outf)
+ def fetch_class_stats(revs):
+ return gather_class_stats(a_branch.repository, revs)
+ display_info(info, self.outf, fetch_class_stats if show_class else None)
commands.register_command(cmd_committer_statistics)
More information about the bazaar-commits
mailing list