Patchwork [2,of,3] localrepo: isolate requirements determination from side effects

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 15, 2016, 9:32 p.m.
Message ID <87d2d6947b2f47d68121.1455571952@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/13215/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Gregory Szorc - Feb. 15, 2016, 9:32 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1455571147 28800
#      Mon Feb 15 13:19:07 2016 -0800
# Node ID 87d2d6947b2f47d6812151ce667918804876d077
# Parent  b99ef6ae4d4407bbed0dbc9074b46fd661604ae6
localrepo: isolate requirements determination from side effects

In preparation for moving requirements determination to its own
function.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -277,41 +277,46 @@  class localrepository(object):
             for setupfunc in self.featuresetupfuncs:
                 if setupfunc.__module__ in extmods:
                     setupfunc(self.ui, self.supported)
         else:
             self.supported = self._basesupported
 
         if not self.vfs.isdir():
             if create:
-                if not self.wvfs.exists():
-                    self.wvfs.makedirs()
-                self.vfs.makedir(notindexed=True)
                 requirements = set(self._baserequirements(create))
                 if self.ui.configbool('format', 'usestore', True):
-                    self.vfs.mkdir("store")
                     requirements.add("store")
                     if self.ui.configbool('format', 'usefncache', True):
                         requirements.add("fncache")
                         if self.ui.configbool('format', 'dotencode', True):
                             requirements.add('dotencode')
-                    # create an invalid changelog
-                    self.vfs.append(
-                        "00changelog.i",
-                        '\0\0\0\2' # represents revlogv2
-                        ' dummy changelog to prevent using the old repo layout'
-                    )
+
                 if scmutil.gdinitconfig(self.ui):
                     requirements.add("generaldelta")
                 if self.ui.configbool('experimental', 'treemanifest', False):
                     requirements.add("treemanifest")
                 if self.ui.configbool('experimental', 'manifestv2', False):
                     requirements.add("manifestv2")
 
                 self.requirements = requirements
+
+                if not self.wvfs.exists():
+                    self.wvfs.makedirs()
+                self.vfs.makedir(notindexed=True)
+
+                if 'store' in requirements:
+                    self.vfs.mkdir("store")
+
+                    # create an invalid changelog
+                    self.vfs.append(
+                        "00changelog.i",
+                        '\0\0\0\2' # represents revlogv2
+                        ' dummy changelog to prevent using the old repo layout'
+                    )
             else:
                 raise error.RepoError(_("repository %s not found") % path)
         elif create:
             raise error.RepoError(_("repository %s already exists") % path)
         else:
             try:
                 self.requirements = scmutil.readrequires(
                         self.vfs, self.supported)