My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday, 7AM PST due to brief network maintenance
                
Search
for
Updated Jun 10, 2009 by haineault
SyncrSubversion  

Syncr: Subversion

Author Copyright (c) 2009 Maxime Haineault (haineault.com)
License MIT License

Warning: Work in progress.

Introduction

Synchronize Subversion commits with django.

Dependencies

Package Website Installation (Debian based distros)
pysvn http://pysvn.tigris.org/ apt-get install pysvn

App

SubversionSyncr

Method Description
syncRevisions Synchronize log from Subversion repository

Models

SubversionSync

Field Type Description
url CharField Repository URL (file, svn and http protocols are supported)
username CharField Username to use for SVN auth
password CharField Password to use for SVN auth
rev_start PositiveIntegerField Revesion start
rev_end PositiveIntegerField Revision end
limit PositiveIntegerField Commit author
discover_changed_paths BooleanField If set to True, the sync will include changed paths*
peg_revision PositiveIntegerField If you find out what id does please tell me :)
include_merged_rev BooleanField Well it will include merged revision ..
strict_node_history BooleanField No idea ..

* Warning: This option make the synchronization significantly longer..

Revision

Field Type Description
revision PositiveIntegerField Revision number
svnPath TextField Full SVN path of the repository
`date DateTimeField Commit timestamp
message TextField Commit message
changed_paths TextField List of changed path (JSON)
author CharField Commit author (unrelated to Django's user system)
revision_kind CharField Revision kind (default is number)
has_children CharField Not really used AFAIK

Synchronizing

For this syncr app I'm playing with an experimental and hopefully easier way to call the script with Django's command management.

First there is two ways to specify your repositories. The first one is to use settings.py to hold your configurations, like this;

SVN_SYNCS = (
    {'url': 'http://django-syncr.googlecode.com/svn/trunk/'},
)

This is the absolute minimal configuration needed. The next thing to do in order to sync is type this command in your project folder;

python manage.py subversion sync

For convenience, I've also created the reset command, which will drop every Revision entries.

python manage.py subversion reset

Before explaining the other method, here's how to specify more options, like authentification and how to override defaults settings for specific repositories;

def authenticate(realm, username, may_save):
    return True, 'MyUserName', 'MyPassword', True

SVN_SYNCS = (
    {'url': 'https://django-syncr.googlecode.com/svn/trunk/', 'get_login': authenticate, 'discover_changed_paths': True, 'end': 50, 'start': 1000},

)

The second method is even easier, if there is no SVN_SYNCS property in settings.py, the script will look into the database and sync every entries found in the table SubversionSync.

You cannot use both method at the same time, it's either one or the other.

Settings

Property Default
SVN_REVISION_START pysvn.Revision(pysvn.opt_revision_kind.head)
SVN_REVISION_END pysvn.Revision(pysvn.opt_revision_kind.number, 0)
SVN_DISCOVER_CHANGED_PATHS True
SVN_STRICT_NODE_HISTORY True
SVN_LIMIT 1000
SVN_PEG_REVISION pysvn.Revision(pysvn.opt_revision_kind.unspecified))
SVN_INCLUDE_MERGED_REVISIONS False

Common Errors

Sync Error: columns revision, svnPath are not unique

For the table Revision I use unique_together on revision and svnPath to enforce uniqueness. So it's normal to see this error when synchronizing.

It only means that the record was already in the database.


Sign in to add a comment
Hosted by Google Code