Child: [529ea4] (diff)

Download this file

reactors.py    25 lines (20 with data), 674 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import errno, logging, os, subprocess
from pylons import c
from pyforge.lib.decorators import audit, react
log = logging.getLogger(__name__)
@audit('scm.hg.init')
def init(routing_key, data):
repo = c.app.repo
repo_name = data['repo_name']
repo_path = data['repo_path']
if not repo_path.endswith('/'): repo_path += '/'
try:
os.makedirs(repo_path)
except OSError, e:
if e.errno != errno.EEXIST:
raise
# We may eventually require --template=...
log.info('hg init '+repo_path+repo_name)
result = subprocess.call(['hg', 'init', repo_name],
cwd=repo_path)
repo.status = 'ready'