SVN: repo-scripts/ciabot_svn.py
arekm
arekm at pld-linux.org
Thu Nov 8 12:40:29 CET 2007
Author: arekm
Date: Thu Nov 8 12:40:29 2007
New Revision: 9017
Modified:
repo-scripts/ciabot_svn.py
Log:
Update. Use XMLRPC by default.
Modified: repo-scripts/ciabot_svn.py
==============================================================================
--- repo-scripts/ciabot_svn.py (original)
+++ repo-scripts/ciabot_svn.py Thu Nov 8 12:40:29 2007
@@ -7,7 +7,7 @@
#
# --------------------------------------------------------------------------
#
-# Copyright (c) 2004-2005, Micah Dowty
+# Copyright (c) 2004-2007, Micah Dowty
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -93,39 +93,50 @@
# r"^ trunk/ (?P<module>[^/]+)/ ",
# r"^ (branches|tags)/ (?P<branch>[^/]+)/ ",
# r"^ (branches|tags)/ (?P<module>[^/]+)/ (?P<branch>[^/]+)/ ",
- r"^ (?P<module>[^/]+)/ trunk/ ",
- r"^ (?P<module>[^/]+)/ (branches|tags)/ (?P<branch>[^/]+)/ ",
- r"^ (?P<module>[^/]+)/ ",
+ r"^ (?P<module>[^/]+)/ trunk/ ",
+ r"^ (?P<module>[^/]+)/ (branches|tags)/ (?P<branch>[^/]+)/ ",
+ r"^ (?P<module>[^/]+)/ ",
]
- # If your repository is accessable over the web, put its base URL here
+ # If your repository is accessible over the web, put its base URL here
# and 'uri' attributes will be given to all <file> elements. This means
# that in CIA's online message viewer, each file in the tree will link
- # directly to the file in your repository
- repositoryURI = "http://svn.pld-linux.org/cgi-bin/viewsvn/"
+ # directly to the file in your repository.
+ repositoryURI = None
+
+ # If your repository is accessible over the web via a tool like ViewVC
+ # that allows viewing information about a full revision, put a format string
+ # for its URL here. You can specify various substitution keys in the Python
+ # syntax: "%(project)s" is replaced by the project name, and likewise
+ # "%(revision)s" and "%(author)s" are replaced by the revision / author.
+ # The resulting URI is added to the data sent to CIA. After this, in CIA's
+ # online message viewer, the commit will link directly to the corresponding
+ # revision page.
+ # revisionURI = None
+ # Example (works for ViewVC as used by SourceForge.net):
+ revisionURI = "http://svn.pld-linux.org/cgi-bin/viewsvn/%(project)s?view=rev&rev=%(revision)s"
# This can be the http:// URI of the CIA server to deliver commits over
# XML-RPC, or it can be an email address to deliver using SMTP. The
# default here should work for most people. If you need to use e-mail
# instead, you can replace this with "cia at cia.navi.cx"
- server = "cia at pld-linux.org"
+ server = "http://cia.navi.cx"
# The SMTP server to use, only used if the CIA server above is an
- # email address
+ # email address.
smtpServer = "localhost"
# The 'from' address to use. If you're delivering commits via email, set
# this to the address you would normally send email from on this host.
fromAddress = "cvs at cvs.pld-linux.org"
- # When nonzero, print the message to stdout instead of delivering it to CIA
+ # When nonzero, print the message to stdout instead of delivering it to CIA.
debug = 0
############# Normally the rest of this won't need modification
-import sys, os, re, urllib
-
+import sys, os, re, urllib, getopt
class File:
"""A file in a Subversion repository. According to our current
@@ -173,7 +184,7 @@
"""A CIA client for Subversion repositories. Uses svnlook to
gather information"""
name = 'Python Subversion client for CIA'
- version = '1.18'
+ version = '1.20'
def __init__(self, repository, revision, config):
self.repository = repository
@@ -231,7 +242,6 @@
)
def makeSourceTag(self):
- self.project = self.config.project
return "<source>%s</source>" % self.makeAttrTags(
'project',
'module',
@@ -245,6 +255,7 @@
'author',
'log',
'diffLines',
+ 'url',
),
self.makeFileTags(),
)
@@ -261,13 +272,19 @@
# then we explicitly slurp that into a unicode object.
return unicode(os.popen(
'LC_ALL="en_US.UTF-8" svnlook %s -r "%s" "%s"' %
- (command, self.revision, self.repository)).read(), 'utf-8')
+ (command, self.revision, self.repository)).read(),
+ 'utf-8', 'replace')
def collectData(self):
self.author = self.svnlook('author').strip()
+ self.project = self.config.project
self.log = self.svnlook('log')
self.diffLines = len(self.svnlook('diff').split('\n'))
self.files = self.collectFiles()
+ if self.config.revisionURI is not None:
+ self.url = self.config.revisionURI % self.__dict__
+ else:
+ self.url = None
def collectFiles(self):
# Extract all the files from the output of 'svnlook changed'
@@ -332,18 +349,53 @@
text = text.replace("\"", """)
return text
-if __name__ == "__main__":
+
+def usage():
+ """Print a short usage description of this script and exit"""
+ sys.stderr.write("Usage: %s [OPTIONS] REPOS-PATH REVISION [PROJECTNAME]\n" %
+ sys.argv[0])
+
+
+def version():
+ """Print out the version of this script"""
+ sys.stderr.write("%s %s\n" % (sys.argv[0], SvnClient.version))
+
+
+def main():
+ try:
+ options = [ "version" ]
+ for key in config.__dict__:
+ if not key.startswith("_"):
+ options.append(key + "=");
+ opts, args = getopt.getopt(sys.argv[1:], "", options)
+ except getopt.GetoptError:
+ usage()
+ sys.exit(2)
+
+ for o, a in opts:
+ if o == "--version":
+ version()
+ sys.exit()
+ else:
+ # Everything else maps straight to a config key. Just have
+ # to remove the "--" prefix from the option name.
+ config.__dict__[o[2:]] = a
+
# Print a usage message when not enough parameters are provided.
- if len(sys.argv) < 3:
- sys.stderr.write("USAGE: %s REPOS-PATH REVISION [PROJECTNAME]\n" %
- sys.argv[0])
- sys.exit(1)
+ if not len(args) in (2,3):
+ sys.stderr.write("%s: incorrect number of arguments\n" % sys.argv[0])
+ usage();
+ sys.exit(2);
# If a project name was provided, override the default project name.
- if len(sys.argv) > 3:
- config.project = sys.argv[3]
+ if len(args) == 3:
+ config.project = args[2]
# Go do the real work.
- SvnClient(sys.argv[1], sys.argv[2], config).main()
+ SvnClient(args[0], args[1], config).main()
+
+
+if __name__ == "__main__":
+ main()
### The End ###
More information about the pld-cvs-commit
mailing list