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
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to