D4549: localrepo: move check for existing repo into createrepository()
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Sep 12 17:50:58 EDT 2018
martinvonz updated this revision to Diff 10977.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D4549?vs=10973&id=10977
REVISION DETAIL
https://phab.mercurial-scm.org/D4549
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
@@ -2378,12 +2378,7 @@
def instance(ui, path, create, intents=None, createopts=None):
if create:
- vfs = vfsmod.vfs(path, expandpath=True, realpath=True)
-
- if vfs.exists('.hg'):
- raise error.RepoError(_('repository %s already exists') % path)
-
- createrepository(ui, vfs, createopts=createopts)
+ createrepository(ui, path, createopts=createopts)
return localrepository(ui, util.urllocalpath(path), intents=intents)
@@ -2459,10 +2454,10 @@
return {k: v for k, v in createopts.items() if k not in known}
-def createrepository(ui, wdirvfs, createopts=None):
+def createrepository(ui, path, createopts=None):
"""Create a new repository in a vfs.
- ``wdirvfs`` is a vfs instance pointing at the working directory.
+ ``path`` path to the new repo's working directory.
``createopts`` options for the new repository.
"""
createopts = createopts or {}
@@ -2481,10 +2476,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)
+
hgvfs.makedir(notindexed=True)
if b'store' in requirements:
To: martinvonz, #hg-reviewers
Cc: pulkit, mercurial-devel
More information about the Mercurial-devel
mailing list