Patchwork [3,of,6] localrepo: make _applyrequirements more specific

login
register
mail settings
Submitter Drew Gottlieb
Date May 1, 2015, 11:19 p.m.
Message ID <9bc80406fce09833ff5a.1430522349@waste.org>
Download mbox | patch
Permalink /patch/8834/
State Accepted
Commit 1c40408770f7410ee2da2fea6e19e87be42bf38a
Headers show

Comments

Drew Gottlieb - May 1, 2015, 11:19 p.m.
# HG changeset patch
# User Drew Gottlieb <drgott@google.com>
# Date 1429729604 25200
#      Wed Apr 22 12:06:44 2015 -0700
# Node ID 9bc80406fce09833ff5a3ab1845337efb2ad30b6
# Parent  202e077a5ff2a8be27cde00807caf4f6b924dbe3
localrepo: make _applyrequirements more specific

Localrepo's _applyrequirements function isn't very straightforward about what
it does. Its purpose is to both act as a setter for the requirements attribute,
and to apply appropriate requirements to the opener's configuration.

This change makes the function just focus on the latter responsibility. We
rename it as such, and make setting the requirements attribute the
responsibility of the caller.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -291,7 +291,8 @@ 
         self.sopener = self.svfs
         self.sjoin = self.store.join
         self.vfs.createmode = self.store.createmode
-        self._applyrequirements(requirements)
+        self.requirements = requirements
+        self._applyopenerreqs()
         if create:
             self._writerequirements()
 
@@ -334,9 +335,8 @@ 
             caps.add('bundle2=' + urllib.quote(capsblob))
         return caps
 
-    def _applyrequirements(self, requirements):
-        self.requirements = requirements
-        self.svfs.options = dict((r, 1) for r in requirements
+    def _applyopenerreqs(self):
+        self.svfs.options = dict((r, 1) for r in self.requirements
                                            if r in self.openerreqs)
         chunkcachesize = self.ui.configint('format', 'chunkcachesize')
         if chunkcachesize is not None:
@@ -1828,7 +1828,8 @@ 
             #                    new format-related
             # requirements from the streamed-in repository
             requirements.update(self.requirements - self.supportedformats)
-            self._applyrequirements(requirements)
+            self.requirements = requirements
+            self._applyopenerreqs()
             self._writerequirements()
 
             if rbranchmap: