[PATCH 3 of 6] localrepo: make _applyrequirements more specific

Drew Gottlieb drgott at google.com
Fri May 1 23:19:09 UTC 2015


# HG changeset patch
# User Drew Gottlieb <drgott at 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.

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:



More information about the Mercurial-devel mailing list