D4549: localrepo: move check for existing repo into createrepository()
This revision was automatically updated to reflect the committed changes. Closed by commit rHGe471cb2852ea: localrepo: move check for existing repo into createrepository() (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D4549?vs=10977=10981 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 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D4549: localrepo: move check for existing repo into createrepository()
martinvonz updated this revision to Diff 10977. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D4549?vs=10973=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 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D4549: localrepo: move check for existing repo into createrepository()
martinvonz added a comment. In https://phab.mercurial-scm.org/D4549#69559, @pulkit wrote: > test-init.t and test-mq.t says hi! Sorry! :( Looks like I forgot to drop the `.hg` argument when I switched from wdirvfs to hgvfs. I'll fix right away. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D4549 To: martinvonz, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D4549: localrepo: move check for existing repo into createrepository()
pulkit added a comment. test-init.t and test-mq.t says hi! --- /storage/pulkit/repo/hgpush/tests/test-init.t +++ /storage/pulkit/repo/hgpush/tests/test-init.t.err @@ -99,7 +99,7 @@ test failure $ hg init local - abort: repository local already exists! + abort: File exists: '$TESTTMP/local/.hg' [255] init+push to remote2 @@ -144,14 +144,14 @@ init to existing repo $ hg init -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote1 - abort: repository remote1 already exists! + abort: File exists: '$TESTTMP/remote1/.hg' abort: could not create remote repo! [255] clone to existing repo $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" local ssh://user@dummy/remote1 - abort: repository remote1 already exists! + abort: File exists: '$TESTTMP/remote1/.hg' abort: could not create remote repo! [255] ERROR: test-init.t output changed ! --- /storage/pulkit/repo/hgpush/tests/test-mq.t +++ /storage/pulkit/repo/hgpush/tests/test-mq.t.err @@ -154,7 +154,7 @@ guards $ cat .hg/patches/series $ hg qinit -c - abort: repository $TESTTMP/d/.hg/patches already exists! + abort: File exists: '$TESTTMP/d/.hg/patches/.hg' [255] $ cd .. ERROR: test-mq.t output changed REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D4549 To: martinvonz, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D4549: localrepo: move check for existing repo into createrepository()
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY For symmetry with the check for existence of a repo in localrepository.__init__, we should check for the non-existence in createrepository(). We could alternatively move both checks into instance(). REPOSITORY rHG Mercurial 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('.hg'): +raise error.RepoError(_('repository %s already exists') % path) + hgvfs.makedir(notindexed=True) if b'store' in requirements: To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel