comparison python/setup_repo.py @ 406:38dd72d72086

fix
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 31 Jul 2013 14:25:02 -0700
parents 815eb5c796e9
children daa9356d614f
comparison
equal deleted inserted replaced
405:815eb5c796e9 406:38dd72d72086
21 """setup repository""" 21 """setup repository"""
22 call(['hg', 'init', directory]) 22 call(['hg', 'init', directory])
23 call(['hg', 'add', '-R', directory]) 23 call(['hg', 'add', '-R', directory])
24 call(['hg', 'commit', '-m', options.message, '-R', directory]) 24 call(['hg', 'commit', '-m', options.message, '-R', directory])
25 25
26 def write_hgrc(directory, host, repo, name):
27 """write hgrc file"""
28
29 HGRC="""[paths]
30 default = http://%(host)s/%(repo)s/%(name)s
31 default-push = ssh://%(host)s/%(repo)s/%(remote_path)s
32 """
33
34 path = os.path.join(directory, '.hg', 'hgrc')
35 # TODO: use ConfigParser
36 with file(os.path.join(directory, '.hg', 'hgrc'), 'w') as f:
37 print >> f, HGRC % { 'host': host, 'repo': repo, 'name': name}
38
39
26 def setup_remote(local_repo, remote_url, push='ssh', remote_path=None): 40 def setup_remote(local_repo, remote_url, push='ssh', remote_path=None):
27 """ 41 """
28 setup a remote repository for local_repo 42 setup a remote repository for local_repo
29 - remote_url : public (pull) URL for remote repository 43 - remote_url : public (pull) URL for remote repository
30 - push : protocol for push 44 - push : protocol for push
41 remote_path = path 55 remote_path = path
42 56
43 # setup remote repository 57 # setup remote repository
44 remote_dir = '%s/%s' % (path, name) 58 remote_dir = '%s/%s' % (path, name)
45 call(['ssh', host, "mkdir -p %s && cd %s && hg init" % (remote_dir, remote_dir)]) 59 call(['ssh', host, "mkdir -p %s && cd %s && hg init" % (remote_dir, remote_dir)])
46
47 def write_hgrc(directory, host, repo, name):
48 """write hgrc file"""
49
50 HGRC="""[paths]
51 default = http://%(host)s/%(repo)s/%(name)s
52 default-push = ssh://%(host)s/%(repo)s/%(name)s
53 """
54
55 path = os.path.join(directory, '.hg', 'hgrc')
56 # TODO: use ConfigParser
57 with file(os.path.join(directory, '.hg', 'hgrc'), 'w') as f:
58 print >> f, HGRC % { 'host': host, 'repo': repo, 'name': name}
59 60
60 61
61 def main(args=sys.argv[1:]): 62 def main(args=sys.argv[1:]):
62 63
63 # parse command line arguments 64 # parse command line arguments