Package buildbot :: Package changes :: Module svnpoller :: Class SVNPoller
[frames] | no frames]

Class SVNPoller

source code

twisted.application.service.Service --+    
                                      |    
               util.ComparableMixin --+    
                                      |    
                      base.ChangeSource --+
                                          |
                   util.ComparableMixin --+
                                          |
                                         SVNPoller

This source will poll a Subversion repository for changes and submit them to the change master.

Instance Methods
 
__init__(self, svnurl, split_file=None, svnuser=None, svnpasswd=None, pollinterval=600, histmax=100, svnbin='svn', revlinktmpl='', category=None) source code
 
split_file(self, path) source code
 
startService(self) source code
 
stopService(self) source code
 
describe(self) source code
 
checksvn(self) source code
 
getProcessOutput(self, args) source code
 
get_root(self) source code
 
determine_prefix(self, output) source code
 
get_logs(self, ignored_prefix=None) source code
 
parse_logs(self, output) source code
 
get_new_logentries(self, logentries) source code
 
create_changes(self, new_logentries) source code
 
submit_changes(self, changes) source code
 
finished_ok(self, res) source code
 
finished_failure(self, f) source code

Inherited from twisted.application.service.Service: __getstate__, __providedBy__, disownServiceParent, privilegedStartService, setName, setServiceParent

Inherited from util.ComparableMixin: __cmp__, __hash__

Class Variables
  compare_attrs = ['svnurl', 'split_file_function', 'svnuser', '...
  parent = None
  last_change = None
  loop = None
  working = False

Inherited from base.ChangeSource: __implemented__, __provides__

Inherited from twisted.application.service.Service: name, running

Method Details

__init__(self, svnurl, split_file=None, svnuser=None, svnpasswd=None, pollinterval=600, histmax=100, svnbin='svn', revlinktmpl='', category=None)
(Constructor)

source code 
Parameters:
  • svnurl (string) - the SVN URL that describes the repository and subdirectory to watch. If this ChangeSource should only pay attention to a single branch, this should point at the repository for that branch, like svn://svn.twistedmatrix.com/svn/Twisted/trunk . If it should follow multiple branches, point it at the repository directory that contains all the branches like svn://svn.twistedmatrix.com/svn/Twisted and also provide a branch-determining function.

    Each file in the repository has a SVN URL in the form (SVNURL)/(BRANCH)/(FILEPATH), where (BRANCH) could be empty or not, depending upon your branch-determining function. Only files that start with (SVNURL)/(BRANCH) will be monitored. The Change objects that are sent to the Schedulers will see (FILEPATH) for each modified file.

  • split_file (callable or None) - a function that is called with a string of the form (BRANCH)/(FILEPATH) and should return a tuple (BRANCH, FILEPATH). This function should match your repository's branch-naming policy. Each changed file has a fully-qualified URL that can be split into a prefix (which equals the value of the 'svnurl' argument) and a suffix; it is this suffix which is passed to the split_file function.

    If the function returns None, the file is ignored. Use this to indicate that the file is not a part of this project.

    For example, if your repository puts the trunk in trunk/... and branches are in places like branches/1.5/..., your split_file function could look like the following (this function is available as svnpoller.split_file_branches):

    pieces = path.split('/')
    if pieces[0] == 'trunk':
        return (None, '/'.join(pieces[1:]))
    elif pieces[0] == 'branches':
        return ('/'.join(pieces[0:2]),
                '/'.join(pieces[2:]))
    else:
        return None
    

    If instead your repository layout puts the trunk for ProjectA in trunk/ProjectA/... and the 1.5 branch in branches/1.5/ProjectA/..., your split_file function could look like:

    pieces = path.split('/')
    if pieces[0] == 'trunk':
        branch = None
        pieces.pop(0) # remove 'trunk'
    elif pieces[0] == 'branches':
        pieces.pop(0) # remove 'branches'
        # grab branch name
        branch = 'branches/' + pieces.pop(0)
    else:
        return None # something weird
    projectname = pieces.pop(0)
    if projectname != 'ProjectA':
        return None # wrong project
    return (branch, '/'.join(pieces))
    

    The default of split_file= is None, which indicates that no splitting should be done. This is equivalent to the following function:

    return (None, path)
    

    If you wish, you can override the split_file method with the same sort of function instead of passing in a split_file= argument.

  • svnuser (string) - If set, the --username option will be added to the 'svn log' command. You may need this to get access to a private repository.
  • svnpasswd (string) - If set, the --password option will be added.
  • pollinterval (int) - interval in seconds between polls. The default is 600 seconds (10 minutes). Smaller values decrease the latency between the time a change is recorded and the time the buildbot notices it, but it also increases the system load.
  • histmax (int) - maximum number of changes to look back through. The default is 100. Smaller values decrease system load, but if more than histmax changes are recorded between polls, the extra ones will be silently lost.
  • svnbin (string) - path to svn binary, defaults to just 'svn'. Use this if your subversion command lives in an unusual location.
  • revlinktmpl (string) - A format string to use for hyperlinks to revision information. For example, setting this to "http://reposerver/websvn/revision.php?rev=%s" would create suitable links on the build pages to information in websvn on each revision.
  • category (string) - A single category associated with the changes that could be used by schedulers watch for branches of a certain name AND category.

startService(self)

source code 
Overrides: twisted.application.service.Service.startService

stopService(self)

source code 
Overrides: twisted.application.service.Service.stopService

Class Variable Details

compare_attrs

Value:
['svnurl',
 'split_file_function',
 'svnuser',
 'svnpasswd',
 'pollinterval',
 'histmax',
 'svnbin',
 'category']