diff utility_commands.py @ 236:c34abd2448b7

Issue #60: Add a svn sub-command to list all authors in a Subversion repository
author Daniel Tang <dytang@cs.purdue.edu>
date Tue, 07 Apr 2009 22:15:22 -0400
parents 33e885f5f86a
children 79349fd04836
line wrap: on
line diff
--- a/utility_commands.py
+++ b/utility_commands.py
@@ -198,6 +198,26 @@ def show_outgoing_to_svn(ui, repo, hg_re
 show_outgoing_to_svn = util.register_subcommand('outgoing')(show_outgoing_to_svn)
 
 
+def list_authors(ui, args, authors=None, **opts):
+    """list all authors in a Subversion repository
+    """
+    if not len(args):
+        ui.status('No repository specified.\n')
+        return
+    svn = svnwrap.SubversionRepo(util.normalize_url(args[0]))
+    author_set = set()
+    for rev in svn.revisions():
+        author_set.add(str(rev.author)) # So None becomes 'None'
+    if authors:
+        authorfile = open(authors, 'w')
+        authorfile.write('%s=\n' % '=\n'.join(sorted(author_set)))
+        authorfile.close()
+    else:
+        ui.status('%s\n' % '\n'.join(sorted(author_set)))
+list_authors = util.register_subcommand('listauthors')(list_authors)
+list_authors = util.command_needs_no_url(list_authors)
+
+
 def version(ui, **opts):
     """Show current version of hg and hgsubversion.
     """