# HG changeset patch # User Gregory Szorc # Date 2018-09-19 23:51:57 # Node ID b504ff813c4f6517e2308a359fa0347b2ef696cd # Parent d3e761f9ac0a74e75c9acd4d7ce712616116cee6 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 diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -2798,13 +2798,14 @@ def createrepository(ui, path, createopt requirements = newreporequirements(ui, createopts=createopts) wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) - if not wdirvfs.exists(): - wdirvfs.makedirs() hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg')) if hgvfs.exists(): raise error.RepoError(_('repository %s already exists') % path) + if not wdirvfs.exists(): + wdirvfs.makedirs() + hgvfs.makedir(notindexed=True) if b'store' in requirements: