Patchwork [1,of,3] localrepo: use local variable for requirements assignment

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 15, 2016, 9:32 p.m.
Message ID <b99ef6ae4d4407bbed0d.1455571951@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/13214/
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 1455403337 28800
#      Sat Feb 13 14:42:17 2016 -0800
# Node ID b99ef6ae4d4407bbed0dbc9074b46fd661604ae6
# Parent  638dcaf3874940349d04f3369ddddc05fd9d5388
localrepo: use local variable for requirements assignment

A future patch will refactor requirements determination into a
standalone function. To prepare for this, refactor the requirements
code to assign to a local variable instead of to self.requirements.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -280,36 +280,38 @@  class localrepository(object):
         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)
-                self.requirements.update(self._baserequirements(create))
+                requirements = set(self._baserequirements(create))
                 if self.ui.configbool('format', 'usestore', True):
                     self.vfs.mkdir("store")
-                    self.requirements.add("store")
+                    requirements.add("store")
                     if self.ui.configbool('format', 'usefncache', True):
-                        self.requirements.add("fncache")
+                        requirements.add("fncache")
                         if self.ui.configbool('format', 'dotencode', True):
-                            self.requirements.add('dotencode')
+                            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):
-                    self.requirements.add("generaldelta")
+                    requirements.add("generaldelta")
                 if self.ui.configbool('experimental', 'treemanifest', False):
-                    self.requirements.add("treemanifest")
+                    requirements.add("treemanifest")
                 if self.ui.configbool('experimental', 'manifestv2', False):
-                    self.requirements.add("manifestv2")
+                    requirements.add("manifestv2")
+
+                self.requirements = requirements
             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)