pysvn - Programmer's reference

This programmer's reference gives complete and detailed infomation on the pysvn API.

The pysvn Programmer's Guide gives an tutorial introduction to the pysvn module.

pysvn features and feature testing

This document covers pysvn version 1.4.0. Features offered by pysvn depend on the version of SVN that is being used. Full functionality is only available with SVN 1.3.0 or later.

Click one of the buttons below to show the pysvn API as supported by a particular version of the SVN.

Sorry you browser does not support the show API buttons. Try viewing this page in FireFox.

Showing the PySVN API supported by SVN 1.3.0. Unsupported parts of the API are show like: This.

The recommended way to test for a feature is to use the python hasattr() builtin. Working out what is and is not support from the version number information is quite complex and unnessesary. For example to test for lock and unlock support:

client = pysvn.Client()
if hasattr( client, 'lock' ):
    # use lock

pysvn module

The pysvn module has the following variables:

The pysvn module has three classes:

The following enumerations are provided:

Use python builtin dir() to list all available values in an enumeration:

    print dir( pysvn.wc_notify_action )

pysvn.Client - Subversion client interface

Interface summary:

client = pysvn.Client()
client = pysvn.Client( config_dir )

The default subversion configuration directory is used if the config_dir is ommitted or set to ''.

The configuration directory is automatically created if it is missing.

A Client object can only be used on one thread at a time. If two threads attempt to call methods of Client at the same time one of the threads will get a pysvn.ClientError exception with the value 'client in use on another thread'.

Variables Callbacks Methods

Client variables

exception_style allows you to control the style of exception raised by pysvn.

pysvn.Client.exception_style

exception_style is used to control how pysvn raises ClientError exceptions.

The default value, 0, makes pysvn raise exceptions as it did prior to pysvn 1.1.2.

exception_style can be set to 0 or 1, see ClientError for details of effect of the style on the exception raised.

Client callbacks

pysvn uses callback functions to allow for realtime feedback and credential handling.

callback_cancel allows you to cancel a long running subversion command.

callback_notify gives feedback as commands runs.

callback_get_log_message is called when a log message is required.

callback_get_login is called to get a username and password to access a repository.

callback_ssl_server_trust_prompt is called when using HTTPS to a server whoes certificate needs is trust verifing.

It is possible to use the Client object without setting up any calls backs. Make sure that all nessesary usernames, passwords and SSL certificate information are stored in the subversion configuration directory.

pysvn.Client.callback_cancel

import pysvn

cancel_command = False
def cancel():
    return cancel_command

client = pysvn.Client()
client.callback_cancel = cancel

The callback_cancel function is called frequently during long running commands. Return True to cause the command to cancel, return False to allow the command to continue.

pysvn.Client.callback_get_log_message

import pysvn

log_message = "reason for change"
def get_log_message():
    return rc, log_message

client = pysvn.Client()
client.callback_get_log_message = get_log_message

The callback_get_log_message is called when a log message is required to complete the current command. Return the True in rc and a log message as a string. Returning False in rc will cause the command to be cancelled. An empty log_message is not allowed and may cause the command to be cancelled.

unicode strings cannot be handled. If you have a unicode string convert to UTF-8.

pysvn.Client.callback_get_login

import pysvn

def get_login( realm, username, may_save ):
    return retcode, username, password, save

client = pysvn.Client()
client.callback_get_login = get_login

callback_get_login is called each time subversion needs a username and password in the realm to access a repository and has no cached credentials.

The may_save parameter is true if subversion is willing to save the answers returned by the callback_get_login function.

pysvn expect the callback_get_login to return a tuple of four values (retcode, username, password, save).

pysvn.Client.callback_notify

import pysvn

def notify( event_dict ):
    return

client = pysvn.Client()
client.callback_notify = notify

The callback_notify is called as a command runs each time an interesting event occurs. The details of the event are passed to the callback_notify function as a dictionary.

The dictionary contains the following values:

pysvn.Client.callback_ssl_client_cert_password_prompt

import pysvn

def ssl_client_cert_password_prompt( realm, may_save ):
    return retcode, password, save

client = pysvn.Client()
client.callback_ssl_client_cert_password_prompt = ssl_client_cert_password_prompt

callback_ssl_client_cert_password_prompt is called each time subversion needs a password in the realm to use a client certificate and has no cached credentials.

The may_save parameter is true if subversion is willing to save the answers returned by the callback_ssl_client_cert_password_prompt function.

pysvn expect the callback_ssl_client_cert_password_prompt to return a tuple of three values (retcode, password, save).

pysvn.Client.callback_ssl_client_cert_prompt

import pysvn

def ssl_client_cert_prompt():
    return retcode, certfile

client = pysvn.Client()
client.callback_ssl_client_cert_prompt = ssl_client_cert_prompt

callback_ssl_client_cert_prompt is called each time subversion needs a client certificate.

pysvn expect the callback_ssl_client_cert_prompt to return a tuple of two values (retcode, certfile).

pysvn.Client.callback_ssl_server_prompt

import pysvn

def ssl_server_prompt( ):
    return 

client = pysvn.Client()
client.callback_ssl_server_prompt = ssl_server_prompt

NOT IMPLEMENTED - what it used for?

pysvn.Client.callback_ssl_server_trust_prompt

import pysvn

def ssl_server_trust_prompt( trust_dict ):
    return retcode, accepted_failures, save

client = pysvn.Client()
client.callback_ssl_server_trust_prompt = ssl_server_trust_prompt

The callback_ssl_server_trust_prompt is called each time an HTTPS server presents a certificate and subversion is not sure if it should be trusted. callback_ssl_server_trust_prompt is called with information about the certificate in trust dict.

pysvn expect the callback_ssl_server_trust_prompt to return a tuple of three values (retcode, accepted_failures, save).

Client methods

add annotate cat checkin checkout cleanup copy
diff diff_peg export get_auth_cache get_auto_props import_ info
info2 is_url log lock ls merge merge_peg
mkdir move propdel propget proplist propset relocate
remove resolved revert revpropdel revpropget revproplist revpropset
set_auth_cache set_auto_props status switch unlock update  

pysvn.Client.add

add( path,
     recurse=True,
     force=False,
     ignore=False )
add( [path,path],
     recurse=True,
     force=False,
     ignore=True )

Schedules all the files or directories specfied in the paths for addition to the repository. Set recurse to True to recursively add a directory's children. Set force to True to force operation to run. Set ignore to False to disregard default and svn:ignore property ignores. Files are added at the next checkin.

pysvn.Client.annotate

file_annotation = \
annotate( url_or_path,
          revision_start=pysvn.Revision( opt_revision_kind.number, 0 ),
          revision_end=pysvn.Revision( opt_revision_kind.head ),
          peg_revision=pysvn.Revision( opt_revision_kind.unspecified ) )
 )

Return the annotation for each line in the url_or_path from revision_start to revision_end.

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

The file_annotation is a list of dictionaries. Each dictionary contains:

pysvn.Client.cat

file_text = \
cat( url_or_path,
     revision=pysvn.Revision( opt_revision_kind.head ),
     peg_revision=pysvn.Revision( opt_revision_kind.unspecified ) )

Return the contents of url_or_path for the specified revision as a string, file_text.

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

pysvn.Client.checkin

revision = \
checkin( path,
        log_message,
        recurse=True,
        keep_locks=False )
revision = \
checkin( [path,path],
        log_message,
        recurse=True,
        keep_locks=False )

checkin the files in the path_list to the repository with the specifed log_message. Set recurse to True to recursively checkin a directory's children with the same log message. Set keep_locks to True to prevent locks in the path being unlocked.

checkin returns a pysvn.Revision containing the number of the checked in revision.

pysvn.Client.checkout

revision = \
checkout( url,
          path,
          recurse=True,
          revision=pysvn.Revision( opt_revision_kind.head ),
          peg_revision=pysvn.Revision( opt_revision_kind.unspecified ),
          ignore_externals=False )

checkout the repository at url into the location specified by path. Set recurse to True to recursively check out a directory's children. Specify a revision to check out a particular version of the source tree. Set ignore_externals to True to ignore externals definitions.

peg_revision indicates in which revision url is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

checkout returns a pysvn.Revision containing the number of the checked out revision.

Note: Subversion seems to return 0 rather then the actual revision. Use a notify callback and record the revision reported for the pysvn.wc_notify_action.update_completed event. This is what the svn command does.

pysvn.Client.cleanup

cleanup( path )

Clean up any locks in the working copy at path. Usually such locks are the result of a failed or interrupted operation.

pysvn.Client.copy

copy( src_url_or_path,
      dest_url_or_path,
      src_revision=pysvn.Revision( opt_revision_kind.head ))

Duplicate something in working copy or repos, remembering history. The src_revision defaults to pysvn.Revision( opt_revision_kind.head ) if the src_path is a URL otherwise to pysvn.Revision( opt_revision_kind.working ).

src_url_or_path and dest_url_or_path can each be either a working copy (WC) path or URL:

If the destination is a URL the client_get_log_message callback must be implemented to return a log message.

pysvn.Client.diff


diff_text = \
diff( tmp_path,
      url_or_path,
      revision1=pysvn.Revision( opt_revision_kind.base ),
      revision2=pysvn.Revision( opt_revision_kind.working ),
      recurse=True,
      ignore_ancestry=False,
      diff_deleted=True,
      ignore_content_type=False,
      header_encoding="" )

return the differences between two revisions of the url_or_path. diff uses tmp_path to create any temporary files needed. Set recurse to True to recursively diff a directory's children. diff_text is a string containing the diff.

Diff output will not be generated for binary files, unless ignore_content_type is true, in which case diffs will be shown regardless of the content types.

Generated headers are encoded using header_encoding.

pysvn.Client.diff_peg


diff_text = \
diff_peg( tmp_path,
          url_or_path,
          peg_revision=pysvn.Revision( opt_revision_kind.unspecified ),
          revision_start=pysvn.Revision( opt_revision_kind.base ),
          revision_end=pysvn.Revision( opt_revision_kind.working ),
          recurse=True,
          ignore_ancestry=False,
          diff_deleted=True,
          ignore_content_type=False,
          header_encoding="" )

return the differences between two revisions of the url_or_path. diff uses tmp_path to create any temporary files needed. Set recurse to True to recursively diff a directory's children. diff_text is a string containing the diff.

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

Diff output will not be generated for binary files, unless ignore_content_type is true, in which case diffs will be shown regardless of the content types.

Generated headers are encoded using header_encoding.

pysvn.Client.export

revision = \
export( src_url_or_path,
        dest_path,
        force=False,
        revision=pysvn.Revision(),
        native_eol=None,
        ignore_externals=False,
        recurse=True,
        peg_revision=pysvn.Revision( opt_revision_kind.unspecified ) )

Create an unversioned copy of the src_path at revision in dest_path. Set recurse to False to export a single file. Set ignore_externals to True to ignore externals definitions.

peg_revision indicates in which revision src_url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

  1. Exports a clean directory tree from the repository specified by URL src_url_or_path, at revision if it is given, otherwise at HEAD, into dest_path.
  2. Exports a clean directory tree from the working copy specified by src_path into dest_path. All local changes will be preserved, but files not under revision control will not be copied.

native_eol parameter allows the line ending of files with svn:eol-style propery set to native to be overriden. Use None to use the eol-style of the Operating System, use "LF" to use "\n", "CR" to use "\r" and "CRLF" to use "\r\n".

export returns a pysvn.Revision containing the number of the checked in revision.

Note: The native_eol parameter is only available for svn 1.1.0 or later.

pysvn.Client.get_auth_cache

enabled = get_auth_cache()

return true if credential caching is enabled, otherwise return false.

pysvn.Client.get_auto_props

enabled = get_auto_props()

Returns true When svn will automatically set properties when adding files otherwise return false.

pysvn.Client.import_

revision = \
import_( path,
         url,
         log_message,
         recurse=True,
         ignore=False )

Commit an unversioned file or tree into the repository.

Recursively commit a copy of PATH to URL. Parent directories are created as necessary in the repository. Set ignore to False to disregard default and svn:ignore property ignores.

import_ returns a pysvn.Revision containing the number of the checked in revision.

pysvn.Client.info

entry = info( path )

return information on path as a Entry object.

pysvn.Client.info2

entry_list = \
info2( url_or_path,
       revision=pysvn.Revision( opt_revision_kind.unspecified ),
       peg_revision=pysvn.Revision( opt_revision_kind.unspecified ),
       recurse=True )

return information on url_or_path as a list of (path, info_dict) tuples. To return information about a URL revision must be opt_revision_kind.head or opt_revision_kind.number.

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

The info_dict contains:

Note: The info2 command is only available with svn 1.2.0 or later.

pysvn.Client.is_url

rc = \
is_url( url )

return True if the url is a known subversion url.

pysvn.Client.lock

lock( url_or_path,
      lock_comment, 
      force=False )

lock the url_or_path with lock_comment. Set force to True to override any lock held by another user.

pysvn.Client.log

log_messages = \
log( url_or_path,
     revision_start=pysvn.Revision( opt_revision_kind.head ),
     revision_end=pysvn.Revision( opt_revision_kind.number, 0 ),
     discover_changed_paths=False,
     strict_node_history=True,
     limit=0 )

return the log messages for the specifed url_or_path between revisions start and end. Set limit to the maximum number of log messages to be returned, 0 means return all messages.

log returns a list of log messges each log messages is a dictionary. The dictionary contains:

pysvn.Client.ls

entries_list = \
ls( url_or_path,
    revision=pysvn.Revision( opt_revision_kind.head ),
    recurse=True,
    peg_revision=pysvn.Revision( opt_revision_kind.unspecified ) )

Returns a list of dictionaries for each file the given path at the provided revision.

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

The dictionary contains:

pysvn.Client.merge

merge( url_or_path1,
       revision1,
       url_or_path2,
       revision2,
       local_path,
       force=False,
       recurse=True )

Apply the differences between two sources to a working copy path.

pysvn.Client.merge_peg

merge_peg( url_or_path,
       revision1,
       revision2,
       peg_revision,
       local_path,
       recurse=True,
       notice_ancestry,
       force=False,
       dry_run=False )

Apply the differences between two sources to a working copy path.

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

pysvn.Client.mkdir

mkdir( url_or_path,
       log_message )
mkdir( [url_or_path,url_or_path],
       log_message )

Create a new directory under revision control.

Create version controlled directories.

If url_or_path is a path, each directory is scheduled for addition upon the next commit.

If url_or_path is a URL, the directories are created in the repository via an immediate commit.

url_or_path can be a list of URLs and paths

In both cases, all the intermediate directories must already exist.

pysvn.Client.move

move( src_url_or_path,
      dest_url_or_path,
      force=False )

Move (rename) something in working copy or HEAD revision of repository.

NOTE: this command is equivalent to a 'copy' and 'delete'.

src_path and dest_path can both be working copy (WC) paths or URLs:

If src_url_or_path is a path, each item is scheduled for deletion upon the next commit. Files, and directories that have not been committed, are immediately removed from the working copy. The command will not remove PATHs that are, or contain, unversioned or modified items; set force=True to override this behaviour.

If src_url_or_path is a URL, the items are deleted from the repository via an immediate commit.

pysvn.Client.propdel

rev = \
propdel( prop_name,
         url_or_path,
         revision=pysvn.Revision(),
         recurse=False,
         skip_checks=False )

Delete the property prop_name from url_or_path.

If skip_checks is true, do no validity checking. But if skip_checks is false, and propname is not a valid property for target, return an error, either SVN_ERR_ILLEGAL_TARGET (if the property is not appropriate for target), or SVN_ERR_BAD_MIME_TYPE (if propname is "svn:mime-type", but propval is not a valid mime-type).

The src_revision defaults to pysvn.Revision( opt_revision_kind.head ) if the src_path is a URL otherwise to pysvn.Revision( opt_revision_kind.working ).

pysvn.Client.propget

prop_list = \
propget( prop_name,
         url_or_path,
         revision=pysvn.Revision(),
         recurse=False,
         peg_revision=pysvn.Revision( opt_revision_kind.unspecified ) )

Returns a dictionary with keys of url_or_path and values of the prop_name.

The src_revision defaults to pysvn.Revision( opt_revision_kind.head ) if the url_or_path is a URL otherwise to pysvn.Revision( opt_revision_kind.working ).

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

pysvn.Client.proplist

prop_list = \
proplist( url_or_path,
          revision=pysvn.Revision(),
          recurse=False,
          peg_revision=pysvn.Revision( opt_revision_kind.unspecified ) )

Returns a list of tuples (path, prop_dict). The prop_dict contains the prop_names and their values if set on the path.

The src_revision defaults to pysvn.Revision( opt_revision_kind.head ) if the url_or_path is a URL otherwise to pysvn.Revision( opt_revision_kind.working ).

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

pysvn.Client.propset

rev = \
propset( prop_name,
         prop_value,
         url_or_path,
         revision=pysvn.Revision(),
         recurse=False,
         skip_checks=False )

Set the property prop_name to prop_value in path.

If skip_checks is true, do no validity checking. But if skip_checks is false, and propname is not a valid property for target, return an error, either SVN_ERR_ILLEGAL_TARGET (if the property is not appropriate for target), or SVN_ERR_BAD_MIME_TYPE (if propname is "svn:mime-type", but propval is not a valid mime-type).

The src_revision defaults to pysvn.Revision( opt_revision_kind.head ) if the url_or_path is a URL otherwise to pysvn.Revision( opt_revision_kind.working ).

peg_revision indicates in which revision url_or_path is valid. If peg_revision.kind is opt_revision_kind.unspecified, then it defaults to opt_revision_kind.head for URLs or opt_revision_kind.working for WC targets.

pysvn.Client.relocate

relocate( from_url,
          to_url,
          path,
          recurse=True)

Relocate the working copy from from_url to to_url of path.

pysvn.Client.remove

remove( url_or_path_list,
        force=False )

If url_or_path is a path, each item is scheduled for deletion upon the next commit. Files, and directories that have not been committed, are immediately removed from the working copy. The command will not remove paths that are, or contain, unversioned or modified items; set force=True to override this behaviour.

If url_or_path is a URL, the items are deleted from the repository via an immediate commit.

pysvn.Client.resolved

resolved( path,
          recurse=True )

Mark the conflicted file at path as resolved.

pysvn.Client.revert

revert( path,
        recurse=False )
revert( [path,path],
        recurse=False )

Discard any changes in the working copy at path. Set recurse to True to recursively revert a directory's children.

pysvn.Client.revpropdel

rev = \
revpropdel( prop_name,
            url,
            revision=pysvn.Revision( opt_revision_kind.head ),
            force=False )

Delete the revision property prop_name from url.

pysvn.Client.revpropget

rev_prop = \
revpropget( prop_name,
            url,
            revision=pysvn.Revision( opt_revision_kind.head ) )

Returns a tuple (rev, prop_val) where the prop_val contains the revision property value.

pysvn.Client.revproplist

rev_prop_dict = \
revproplist( url,
             revision=pysvn.Revision( opt_revision_kind.head ) )

Returns a tuple (revision, prop_dict) where the prop_dict contains the revision properies and their values.

pysvn.Client.revpropset

rev = \
revpropset( prop_name,
            prop_value,
            url,
            revision=pysvn.Revision( opt_revision_kind.head ),
            force=False )

set the revision property prop_name to prop_value in path. The revision updated is returned.

pysvn.Client.set_auth_cache

set_auth_cache( enable )

When enable is True subversion will remember authentication credentials in the configuration directory.

pysvn.Client.set_auto_props

set_auto_props( enable )

When enabled subversion will automatically set properties when adding files otherwise when disabled will not.

pysvn.Client.status

status_list = \
status( path,
        recurse=True,
        get_all=True,
        update=False,
        ignore=False,
        ignore_externals=False )

If path is a directory status is returned for all files in the directory in status_list. If path is a single file status is returned for that single file in status_list. Set ignore_externals to True to ignore externals definitions.

The status_list is a list of status objects.

Options:

pysvn.Client.switch

switch( path,
        url,
        recurse=True,
        revision=pysvn.Revision( opt_revision_kind.head ) )

Update the working copy to a different URL.

  1. Update the working copy to mirror a new URL. This behaviour is a superset of "svn update". Note: this is the way to move a working copy to a new branch.
  2. Reconnect the working copy when the repository URL has changed.

pysvn.Client.unlock

unlock( url_or_path,
        force=False )

Unlock the url_or_path. Set force to True to unlock any lock held by another user.

pysvn.Client.update

revision = \
update( path,
        recurse=True,
        revision=pysvn.Revision( opt_revision_kind.head ),
        ignore_externals=False )

Update the file in the working copy at path to the specified revision. Set recurse to True to recursively update a directory's children. Set ignore_externals to True to ignore externals definitions.

update returns a pysvn.Revision containing the number of the revision the working copy was updated to.

This command is typically used to get the latest changes from the repository.

Note: updating to an older revision does not change the current revision. To make the current version identical to an older revision, use a merge followed by a commit.

pysvn.Transaction - Subversion transaction interface

Interface summary:

transaction = pysvn.Transaction()
transaction = pysvn.Transaction( repos_path, transaction_name )

The Transaction object allows you to implement hook code for the SVN repository. The pre-commit and pre-revprop-change hooks are the only hooks that are currently appropiate in SVN. See the SVN documentation for details on hook scripts.

A Transaction object can only be used on one thread at a time. If two threads attempt to call methods of Transaction at the same time one of the threads will get a pysvn.TransactionError exception with the value 'transaction in use on another thread'.

Transaction methods

cat changed    
propdel propget proplist propset
revpropdel revpropget revproplist revpropset

pysvn.Transaction.cat

file_text = \
cat( path )

Return the contents of path as a string, file_text.

pysvn.Transaction.changed

file_text = \
changed()

Return a dict of all changes in the transaction. The keys in the dict are the path names and the values are tuples contraining action, kind, text_mod, prop_mod.

pysvn.Transaction.propdel

propdel( prop_name,
         path )

Delete the property prop_name from path in the transaction.

pysvn.Transaction.propget

prop_value = \
propget( prop_name,
         path )

Returns the prop_value as a string or None if the prop_name is not in the transaction.

pysvn.Transaction.proplist

prop_dict = \
proplist( path )

Returns a prop_dict. The prop_dict contains the prop_names and their values if set on the path in the transaction.

pysvn.Transaction.propset

propset( prop_name,
         prop_value,
         path )

Set the property prop_name to prop_value in path in the transaction.

pysvn.Transaction.revpropdel

revpropdel( prop_name )

Delete the revision property prop_name in the transaction.

pysvn.Transaction.revpropget

prop_val = \
revpropget( prop_name )

Returns the prop_val with the revision property value or None if not set in the transaction.

pysvn.Transaction.revproplist

prop_dict = \
revproplist()

Returns a prop_dict where the prop_dict contains the revision properies and their values in the transaction.

pysvn.Transaction.revpropset

rev = \
revpropset( prop_name,
            prop_value )

set the revision property prop_name to prop_value in path in the transaction. The revision updated is returned.

pysvn.Revision - subversion revision

The Revision object has three member variables:

Interface summary:

import pysvn
import time

revhead = pysvn.Revision( pysvn.opt_revision_kind.head )
revdate = pysvn.Revision( pysvn.opt_revision_kind.date, time.time() )
revnum = pysvn.Revision( pysvn.opt_revision_kind.number, 4721 )

pysvn.ClientError - Exception class raised by client commands on error

ClientError exception is raised when any of the subversion functions called by pysvn return an error.

The Client.exception_style variable controls the information stored in the ClientError object.

exception_style = 0

The arg property is set to a single string parameter containing the whole error message. '\n' is used to seperate message parts.

Use str() to get the string description of the exception raised by pysvn.

import pysvn

client = pysvn.Client()
client.exception_style = 0
try:

    client.update( '' )
except pysvn.ClientError, e:
    # convert to a string
    print str(e)
    # or access the string in arg directly
    print e.arg

exception_style = 1

The arg property is set to a tuple contain two values.

arg[0] is set to a string parameter containing the whole error message. '\n' is used to seperate message parts.

arg[1] is set to a list of tuples containing the message string and the error code. The error code values are defined by SVN and APR.

import pysvn

client = pysvn.Client()
client.exception_style = 1
try:

    client.update( '' )
except pysvn.ClientError, e:
    # print the whole message
    print e.arg[0]
    # or process the error list
    for message, code in e.arg[1]:
        print 'Code:',code,'Message:',message

pysvn.Status - subversion status object

Each status object has the following fields:

pysvn.Entry - subversion entry object

Copyright © 2004-2006 Barry A. Scott. All rigths reserved.