Patchwork [6,of,6] localrepo: eliminate local requirements var in init

login
register
mail settings
Submitter Drew Gottlieb
Date May 1, 2015, 11:19 p.m.
Message ID <db35104e8986761bad92.1430522352@waste.org>
Download mbox | patch
Permalink /patch/8837/
State Accepted
Commit 2eac3ae0d0886762783e974ccbc748bafeb757ca
Headers show

Comments

Drew Gottlieb - May 1, 2015, 11:19 p.m.
# HG changeset patch
# User Drew Gottlieb <drgott@google.com>
# Date 1429731188 25200
#      Wed Apr 22 12:33:08 2015 -0700
# Node ID db35104e8986761bad929c5f042aad65e92c01c8
# Parent  e18209d2abdc45ba974d6c780c57428ca271d1f6
localrepo: eliminate local requirements var in init

Localrepo's __init__ function creates a local requirements set to add to before
it replaces the instance's set with it. This is unnecessary, so let's just
use the instance's set directly.
Matt Mackall - May 4, 2015, 5:41 p.m.
On Fri, 2015-05-01 at 18:19 -0500, Drew Gottlieb wrote:
> # HG changeset patch
> # User Drew Gottlieb <drgott@google.com>
> # Date 1429731188 25200
> #      Wed Apr 22 12:33:08 2015 -0700
> # Node ID db35104e8986761bad929c5f042aad65e92c01c8
> # Parent  e18209d2abdc45ba974d6c780c57428ca271d1f6
> localrepo: eliminate local requirements var in init

These are queued for default, thanks.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -206,6 +206,7 @@ 
         return ['revlogv1']
 
     def __init__(self, baseui, path=None, create=False):
+        self.requirements = set()
         self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True)
         self.wopener = self.wvfs
         self.root = self.wvfs.base
@@ -242,14 +243,14 @@ 
                 if not self.wvfs.exists():
                     self.wvfs.makedirs()
                 self.vfs.makedir(notindexed=True)
-                requirements = set(self._baserequirements(create))
+                self.requirements.update(self._baserequirements(create))
                 if self.ui.configbool('format', 'usestore', True):
                     self.vfs.mkdir("store")
-                    requirements.add("store")
+                    self.requirements.add("store")
                     if self.ui.configbool('format', 'usefncache', True):
-                        requirements.add("fncache")
+                        self.requirements.add("fncache")
                         if self.ui.configbool('format', 'dotencode', True):
-                            requirements.add('dotencode')
+                            self.requirements.add('dotencode')
                     # create an invalid changelog
                     self.vfs.append(
                         "00changelog.i",
@@ -257,20 +258,20 @@ 
                         ' dummy changelog to prevent using the old repo layout'
                     )
                 if self.ui.configbool('format', 'generaldelta', False):
-                    requirements.add("generaldelta")
+                    self.requirements.add("generaldelta")
                 if self.ui.configbool('experimental', 'manifestv2', False):
-                    requirements.add("manifestv2")
+                    self.requirements.add("manifestv2")
             else:
                 raise error.RepoError(_("repository %s not found") % path)
         elif create:
             raise error.RepoError(_("repository %s already exists") % path)
         else:
             try:
-                requirements = scmutil.readrequires(self.vfs, self.supported)
+                self.requirements = scmutil.readrequires(
+                        self.vfs, self.supported)
             except IOError, inst:
                 if inst.errno != errno.ENOENT:
                     raise
-                requirements = set()
 
         self.sharedpath = self.path
         try:
@@ -285,13 +286,13 @@ 
             if inst.errno != errno.ENOENT:
                 raise
 
-        self.store = store.store(requirements, self.sharedpath, scmutil.vfs)
+        self.store = store.store(
+                self.requirements, self.sharedpath, scmutil.vfs)
         self.spath = self.store.path
         self.svfs = self.store.vfs
         self.sopener = self.svfs
         self.sjoin = self.store.join
         self.vfs.createmode = self.store.createmode
-        self.requirements = requirements
         self._applyopenerreqs()
         if create:
             self._writerequirements()