Changeset 4076

Show
Ignore:
Timestamp:
07/29/08 12:03:29 (5 months ago)
Author:
k0s
Message:

updates to generalize the svnsync plugin for windows (untested on windows); hopefully fixes #3361 ; cleanup; bump microversion to reflect change

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • svnsyncplugin/0.11/setup.py

    r3750 r4076  
    11from setuptools import find_packages, setup 
    22 
    3 version='0.1
     3version='0.1.1
    44 
    55setup(name='svnsyncplugin', 
     
    99      author_email='jhammel@openplans.org', 
    1010      url='http://trac-hacks.org/wiki/SvnsyncPlugin', 
    11       keywords='trac plugin', 
     11      keywords='trac plugin svn', 
    1212      license="GPL", 
    1313      packages=find_packages(exclude=['ez_setup', 'examples', 'tests*']), 
  • svnsyncplugin/0.11/svnsyncplugin/svnsync.py

    r3750 r4076  
    99import os 
    1010import subprocess 
     11 
     12windows = [ 'nt' ] # special-casing for windows OS;  POSIX assumed otherwise 
    1113 
    1214def sh(*args, **kw): 
     
    2224    stdout, stderr = process.communicate() 
    2325    return (stdout, stderr, process.wait()) 
    24      
     26 
     27def file_uri(path): 
     28    # this should really live elsewhere 
     29    if os.name in windows:  
     30        uri = 'file:///' + os.path.abspath(path)  
     31        uri = uri.replace('\\','/')  
     32    else:  
     33        uri = 'file://' + os.path.abspath(path)  
     34    return uri 
    2535 
    2636def create(directory, repository, username='svnsync'): 
     
    3040 
    3141    sh('svnadmin', 'create', directory) 
    32     filename = os.path.join(directory, 'hooks', 'pre-revprop-change') 
     42 
     43    filename = 'pre-revprop-change' 
     44    if os in windows: 
     45        filename += '.bat' 
     46    filename = os.path.join(directory, 'hooks', filename) 
     47    os.mknod(filename, 0770) 
    3348    f = file(filename, 'w') 
    34     print >> f, '#!/bin/sh' 
    35     f.close() 
    36  
    37     # XXX only works if chmod on the path; 
    38     # this should retrieve the file permissions and then 
    39     # set them appropriate with os.chmod 
    40     sh('chmod', '+x', filename)  
     49    if os in windows: 
     50        print >> f, '' 
     51    else: 
     52        print >> f, '#!/bin/sh' 
     53        f.close() 
    4154 
    4255    ### initialize the sync 
    4356 
    4457    return sh('svnsync', 'init', '--username', username,  
    45               'file://%s' % os.path.abspath(directory), 
    46               repository) 
     58              file_uri(directory), repository) 
    4759 
    4860def sync(directory, repository, username='svnsync'): 
    4961 
    5062    # create the mirror if it doesn't exist 
    51     # 
    52     # XXX this should be a much better check,  
    53     # probably using `svn info` to check if the url is the 
    54     # same as repository 
    5563    if not os.path.exists(directory): 
    5664        retval = create(directory, repository, username) 
     
    5866            return retval 
    5967 
    60     repo = 'file://%s' % os.path.abspath(directory) 
     68    repo = file_uri(directory) 
    6169 
    6270    # ensure that the repository is pointed at the right place