D6935: vfs: give all vfs an options attribute by default

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Tue Oct 1 13:08:44 EDT 2019


Closed by commit rHG3518da504303: vfs: give all vfs an options attribute by default (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6935?vs=16749&id=16755

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6935/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6935

AFFECTED FILES
  contrib/dumprevlog
  mercurial/revlog.py
  mercurial/statichttprepo.py
  mercurial/vfs.py
  tests/test-parseindex.t

CHANGE DETAILS

diff --git a/tests/test-parseindex.t b/tests/test-parseindex.t
--- a/tests/test-parseindex.t
+++ b/tests/test-parseindex.t
@@ -53,6 +53,7 @@
   >     def wrapper(*a, **kwargs):
   >         f = o(*a, **kwargs)
   >         return singlebyteread(f)
+  >     wrapper.options = o.options
   >     return wrapper
   > 
   > cl = changelog.changelog(opener(b'.hg/store'))
diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -327,6 +327,7 @@
             self.audit = (lambda path, mode=None: True)
         self.createmode = None
         self._trustnlink = None
+        self.options = {}
 
     @util.propertycache
     def _cansymlink(self):
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -115,6 +115,7 @@
     class statichttpvfs(vfsmod.abstractvfs):
         def __init__(self, base):
             self.base = base
+            self.options = {}
 
         def __call__(self, path, mode='r', *args, **kw):
             if mode not in ('r', 'rb'):
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -355,7 +355,7 @@
 
     def _loadindex(self):
         mmapindexthreshold = None
-        opts = getattr(self.opener, 'options', {}) or {}
+        opts = self.opener.options
 
         if 'revlogv2' in opts:
             newversionflags = REVLOGV2 | FLAG_INLINE_DATA
@@ -363,7 +363,7 @@
             newversionflags = REVLOGV1 | FLAG_INLINE_DATA
             if 'generaldelta' in opts:
                 newversionflags |= FLAG_GENERALDELTA
-        elif 'revlogv0' in getattr(self.opener, 'options', {}):
+        elif 'revlogv0' in self.opener.options:
             newversionflags = REVLOGV0
         else:
             newversionflags = REVLOG_DEFAULT_VERSION
diff --git a/contrib/dumprevlog b/contrib/dumprevlog
--- a/contrib/dumprevlog
+++ b/contrib/dumprevlog
@@ -22,6 +22,7 @@
     if b'b' not in mode:
         mode = mode + b'b'
     return open(path, pycompat.sysstr(mode))
+binopen.options = {}
 
 def printb(data, end=b'\n'):
     sys.stdout.flush()



To: marmoute, martinvonz, durin42, indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list