Mercurial > public > mercurial-scm > hg
diff hgext/convert/hg.py @ 5441:71e7c86adcb7
convert: refactor sink initialisation, to remove hardcoding of hg
We also introduce options to explicitly set the source and destination
repository types.
Improve testing of corner cases a little.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Wed, 10 Oct 2007 15:42:00 -0700 |
parents | b4ae8535f834 |
children | 03496d4fa509 |
line wrap: on
line diff
--- a/hgext/convert/hg.py Wed Oct 10 15:30:00 2007 -0700 +++ b/hgext/convert/hg.py Wed Oct 10 15:42:00 2007 -0700 @@ -21,10 +21,22 @@ self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False) self.tagsbranch = ui.config('convert', 'hg.tagsbranch', 'default') self.lastbranch = None - try: - self.repo = hg.repository(self.ui, path) - except: - raise NoRepo("could not open hg repo %s as sink" % path) + if os.path.isdir(path) and len(os.listdir(path)) > 0: + try: + self.repo = hg.repository(self.ui, path) + ui.status(_('destination %s is a Mercurial repository\n') % + path) + except hg.RepoError, err: + ui.print_exc() + raise NoRepo(err.args[0]) + else: + try: + ui.status(_('initializing destination %s repository\n') % path) + self.repo = hg.repository(self.ui, path, create=True) + self.created.append(path) + except hg.RepoError, err: + ui.print_exc() + raise NoRepo("could not create hg repo %s as sink" % path) self.lock = None self.wlock = None self.filemapmode = False