Parent: [f4f159] (diff)

Child: [195a5c] (diff)

Download this file

svn.py    65 lines (52 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import sys
import logging
import genshi
import pylons
import pkg_resources
from pymongo import bson
from forgescm import model as M
from .command import Command
from . import hg
log = logging.getLogger(__name__)
class init(Command):
base='svnadmin create .'
class sync(Command):
base = 'svnsync'
class rebase(Command):
base='hg rebase --svn'
def cwd(self):
return Command.cwd(self) + '/hg_repo'
def svn_clone(remote):
'''Clone one svn repo using svnsync'''
# Create the svn repo
cmd = init()
cmd.clean_dir()
cmd.run_exc()
# Allow svnsync to change revprops
revprop_hook = os.path.join(
cmd.cwd(),
'./hooks/pre-revprop-change')
# os.remove(revprop_hook)
os.symlink('/bin/true', revprop_hook)
# Use svnsync to clone svn=>svn
sync('init', 'file://%s' % cmd.cwd(), 'file://%s' % remote).run_exc()
sync('sync', 'file://%s' % cmd.cwd()).run_exc()
def setup_scmweb(self, repo_dir):
return
def setup_commit_hook(repo_dir, plugin_id):
'Set up the svn post-commit hook'
tpl_fn = pkg_resources.resource_filename(
'forgescm', 'data/svn/post-commit_tmpl')
tpl_text = open(tpl_fn).read()
tt = genshi.template.NewTextTemplate(
tpl_text, filepath=os.path.dirname(tpl_fn), filename=tpl_fn)
context = dict(
executable=sys.executable,
repository=plugin_id,
config=pylons.config['__file__'])
strm = tt.generate(**context)
fn = os.path.join(repo_dir, 'hooks/post-commit')
with open(fn, 'w') as fp:
fp.write(strm.render())
os.chmod(fn, 0755)