Mercurial > hg > config
comparison python/setup_repo.py @ 457:cdad4c445993
python/setup_repo.py
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Sat, 10 Aug 2013 18:07:02 -0700 |
| parents | 7f1dfb36a0fe |
| children | 483b4237d9a2 |
comparison
equal
deleted
inserted
replaced
| 456:7f1dfb36a0fe | 457:cdad4c445993 |
|---|---|
| 19 import urlparse | 19 import urlparse |
| 20 | 20 |
| 21 from optparse import OptionParser | 21 from optparse import OptionParser |
| 22 | 22 |
| 23 string = (basestring,) | 23 string = (basestring,) |
| 24 | |
| 25 # global variables that probably shouldn't be | |
| 26 dry_run = True | |
| 27 verbose = True | |
| 24 | 28 |
| 25 def call(command, *args, **kwargs): | 29 def call(command, *args, **kwargs): |
| 26 | 30 |
| 27 if isinstance(command, string): | 31 if isinstance(command, string): |
| 28 command_str = command | 32 command_str = command |
| 44 default = http://%(host)s/%(repo)s/%(name)s | 48 default = http://%(host)s/%(repo)s/%(name)s |
| 45 default-push = ssh://%(host)s/%(repo)s/%(remote_path)s | 49 default-push = ssh://%(host)s/%(repo)s/%(remote_path)s |
| 46 """ | 50 """ |
| 47 | 51 |
| 48 path = os.path.join(directory, '.hg', 'hgrc') | 52 path = os.path.join(directory, '.hg', 'hgrc') |
| 49 # TODO: use ConfigParser | 53 # TODO: use ConfigParser and i.e |
| 54 # http://k0s.org/hg/config/file/95afeaf9c42d/python/hgrc.py | |
| 50 with file(os.path.join(directory, '.hg', 'hgrc'), 'w') as f: | 55 with file(os.path.join(directory, '.hg', 'hgrc'), 'w') as f: |
| 51 print >> f, HGRC % { 'host': host, 'repo': repo, 'name': name} | 56 print >> f, HGRC % { 'host': host, 'repo': repo, 'name': name} |
| 52 | 57 |
| 53 | 58 |
| 54 def setup_remote(local_repo, remote_url, push='ssh', remote_path=None, name=None): | 59 def setup_remote(local_repo, remote_url, push='ssh', remote_path=None, name=None): |
| 103 parser.add_option('-p', '--remote-path', dest='remote_path', | 108 parser.add_option('-p', '--remote-path', dest='remote_path', |
| 104 help="remote path of hg repository links; otherwise taken from --remote-url, if specified") | 109 help="remote path of hg repository links; otherwise taken from --remote-url, if specified") |
| 105 parser.add_option('-o', '--remote-only', dest='remote_only', | 110 parser.add_option('-o', '--remote-only', dest='remote_only', |
| 106 action='store_true', default=False, | 111 action='store_true', default=False, |
| 107 help="setup remote server only") | 112 help="setup remote server only") |
| 113 parser.add_option('--dry-run', dest='dry_run', | |
| 114 action='store_true', default=True, | |
| 115 help="") | |
| 108 options, args = parser.parse_args(args) | 116 options, args = parser.parse_args(args) |
| 109 | 117 |
| 110 # sanitization | 118 # sanitization |
| 111 if not args: | 119 if not args: |
| 112 args = [os.getcwd()] | 120 args = [os.getcwd()] |
