[PATCH 2 of 6] localrepo: make requirements always be a set in localrepo.__init__

Drew Gottlieb drgott at google.com
Fri May 1 18:19:08 CDT 2015


# HG changeset patch
# User Drew Gottlieb <drgott at google.com>
# Date 1429661770 25200
#      Tue Apr 21 17:16:10 2015 -0700
# Node ID 202e077a5ff2a8be27cde00807caf4f6b924dbe3
# Parent  07d39152e3f49c717296ebbe0e543319404f1447
localrepo: make requirements always be a set in localrepo.__init__

The init function used to create a local list, and then convert it to a set
before assigning it as a data attribute. This change simplifies the function by
having it always be a set, requiring no conversion.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -242,14 +242,14 @@
                 if not self.wvfs.exists():
                     self.wvfs.makedirs()
                 self.vfs.makedir(notindexed=True)
-                requirements = self._baserequirements(create)
+                requirements = set(self._baserequirements(create))
                 if self.ui.configbool('format', 'usestore', True):
                     self.vfs.mkdir("store")
-                    requirements.append("store")
+                    requirements.add("store")
                     if self.ui.configbool('format', 'usefncache', True):
-                        requirements.append("fncache")
+                        requirements.add("fncache")
                         if self.ui.configbool('format', 'dotencode', True):
-                            requirements.append('dotencode')
+                            requirements.add('dotencode')
                     # create an invalid changelog
                     self.vfs.append(
                         "00changelog.i",
@@ -257,10 +257,9 @@
                         ' dummy changelog to prevent using the old repo layout'
                     )
                 if self.ui.configbool('format', 'generaldelta', False):
-                    requirements.append("generaldelta")
+                    requirements.add("generaldelta")
                 if self.ui.configbool('experimental', 'manifestv2', False):
-                    requirements.append("manifestv2")
-                requirements = set(requirements)
+                    requirements.add("manifestv2")
             else:
                 raise error.RepoError(_("repository %s not found") % path)
         elif create:
@@ -1828,7 +1827,7 @@
             # new requirements = old non-format requirements +
             #                    new format-related
             # requirements from the streamed-in repository
-            requirements.update(set(self.requirements) - self.supportedformats)
+            requirements.update(self.requirements - self.supportedformats)
             self._applyrequirements(requirements)
             self._writerequirements()
 


More information about the Mercurial-devel mailing list