D4706: localrepo: validate directories before creating any
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Mon Sep 24 16:13:13 UTC 2018
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4706
AFFECTED FILES
mercurial/localrepo.py
CHANGE DETAILS
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2798,13 +2798,14 @@
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:
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list