Mercurial > hg-stable
changeset 3035:4d0e0f149581
localrepo: move the repo creation code, fail if the repo exists
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sat, 02 Sep 2006 23:06:47 +0200 |
parents | 2b0bc36a48d8 |
children | adf7f3421c55 |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sat Sep 02 21:08:54 2006 +0200 +++ b/mercurial/localrepo.py Sat Sep 02 23:06:47 2006 +0200 @@ -31,8 +31,16 @@ path = p self.path = os.path.join(path, ".hg") - if not create and not os.path.isdir(self.path): - raise repo.RepoError(_("repository %s not found") % path) + if not os.path.isdir(self.path): + if create: + if not os.path.exists(path): + os.mkdir(path) + os.mkdir(self.path) + os.mkdir(self.join("data")) + else: + raise repo.RepoError(_("repository %s not found") % path) + elif create: + raise repo.RepoError(_("repository %s already exists") % path) self.root = os.path.abspath(path) self.origroot = path @@ -75,12 +83,6 @@ self.decodepats = None self.transhandle = None - if create: - if not os.path.exists(path): - os.mkdir(path) - os.mkdir(self.path) - os.mkdir(self.join("data")) - self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root) def url(self):