Mercurial > hg
comparison mercurial/localrepo.py @ 39847:b504ff813c4f
localrepo: validate directories before creating any
There is no meaningful change in behavior because wdir would
already exist in the case where we raised RepoError. But I think
the code is easier to read if we do all validation first then
take actions with side-effects.
Differential Revision: https://phab.mercurial-scm.org/D4706
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 19 Sep 2018 16:51:57 -0700 |
parents | d3e761f9ac0a |
children | 4ece3cdfd907 |
comparison
equal
deleted
inserted
replaced
39846:d3e761f9ac0a | 39847:b504ff813c4f |
---|---|
2796 hint=_('is a required extension not loaded?')) | 2796 hint=_('is a required extension not loaded?')) |
2797 | 2797 |
2798 requirements = newreporequirements(ui, createopts=createopts) | 2798 requirements = newreporequirements(ui, createopts=createopts) |
2799 | 2799 |
2800 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) | 2800 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
2801 if not wdirvfs.exists(): | |
2802 wdirvfs.makedirs() | |
2803 | 2801 |
2804 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg')) | 2802 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg')) |
2805 if hgvfs.exists(): | 2803 if hgvfs.exists(): |
2806 raise error.RepoError(_('repository %s already exists') % path) | 2804 raise error.RepoError(_('repository %s already exists') % path) |
2805 | |
2806 if not wdirvfs.exists(): | |
2807 wdirvfs.makedirs() | |
2807 | 2808 |
2808 hgvfs.makedir(notindexed=True) | 2809 hgvfs.makedir(notindexed=True) |
2809 | 2810 |
2810 if b'store' in requirements: | 2811 if b'store' in requirements: |
2811 hgvfs.mkdir(b'store') | 2812 hgvfs.mkdir(b'store') |