Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/commands.py @ 1205:4003ea658693
Write out hgrc properly.
Previously, we simply appended to the hgrc file, which meant that it
ended up containing multiple "paths" sections. Now, we only modify
"paths.default".
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun, 04 Sep 2005 15:47:59 -0700 |
parents | 71111d796e40 |
children | 6512d352d6c1 |
comparison
equal
deleted
inserted
replaced
1204:b0f6053df539 | 1205:4003ea658693 |
---|---|
8 from demandload import demandload | 8 from demandload import demandload |
9 from node import * | 9 from node import * |
10 demandload(globals(), "os re sys signal shutil imp") | 10 demandload(globals(), "os re sys signal shutil imp") |
11 demandload(globals(), "fancyopts ui hg util lock revlog") | 11 demandload(globals(), "fancyopts ui hg util lock revlog") |
12 demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") | 12 demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") |
13 demandload(globals(), "errno socket version struct atexit sets") | 13 demandload(globals(), "ConfigParser errno socket version struct atexit sets") |
14 | 14 |
15 class UnknownCommand(Exception): | 15 class UnknownCommand(Exception): |
16 """Exception raised if command is not in the command table.""" | 16 """Exception raised if command is not in the command table.""" |
17 | 17 |
18 def filterfiles(filters, files): | 18 def filterfiles(filters, files): |
620 | 620 |
621 else: | 621 else: |
622 repo = hg.repository(ui, dest, create=1) | 622 repo = hg.repository(ui, dest, create=1) |
623 repo.pull(other) | 623 repo.pull(other) |
624 | 624 |
625 f = repo.opener("hgrc", "a") | 625 cfg = ConfigParser.SafeConfigParser() |
626 f.write("\n[paths]\n") | 626 try: |
627 f.write("default = %s\n" % abspath) | 627 fp = repo.opener('hgrc', 'r') |
628 os.unlink(fp.name) | |
629 cfg.readfp(fp) | |
630 except IOError, inst: | |
631 if inst.errno != errno.ENOENT: raise | |
632 if not cfg.has_section('paths'): cfg.add_section('paths') | |
633 cfg.set('paths', 'default', abspath) | |
634 cfg.write(repo.opener('hgrc', 'w')) | |
628 | 635 |
629 if not opts['noupdate']: | 636 if not opts['noupdate']: |
630 update(ui, repo) | 637 update(ui, repo) |
631 | 638 |
632 d.close() | 639 d.close() |