[PATCH 4 of 6 RFC] localrepo: move repoview to immutable class
Gregory Szorc
gregory.szorc at gmail.com
Fri Jun 9 02:36:08 EDT 2017
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1496980831 25200
# Thu Jun 08 21:00:31 2017 -0700
# Node ID 0b779b2671892a99bce634078b84eae13aa6a189
# Parent addfd306f838ccc177cc68983bb6d41a585edd3e
localrepo: move repoview to immutable class
unfiltered() is generic and can be moved outright.
filtered() uses a different repoview class on the immutable instance.
So the implementation is copied and modified as appropriate. The
docstring and comments go with it though.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -466,6 +466,21 @@ class immutablelocalrepository(object):
def _writerequirements(self):
scmutil.writerequires(self.vfs, self.requirements)
+ def unfiltered(self):
+ """Return unfiltered version of the repository
+
+ Intended to be overwritten by filtered repo."""
+ return self
+
+ def filtered(self, name):
+ """Return a filtered version of a repository"""
+ # build a new class with the mixin and the current class
+ # (possibly subclass of the repo)
+ base = self.unfiltered().__class__
+ class filteredrepo(repoview.immutablerepoview, base):
+ pass
+ return filteredrepo(self, name)
+
class localrepository(immutablelocalrepository):
def __init__(self, baseui, path, create=False):
@@ -508,16 +523,7 @@ class localrepository(immutablelocalrepo
def peer(self):
return localpeer(self) # not cached to avoid reference cycle
- def unfiltered(self):
- """Return unfiltered version of the repository
-
- Intended to be overwritten by filtered repo."""
- return self
-
def filtered(self, name):
- """Return a filtered version of a repository"""
- # build a new class with the mixin and the current class
- # (possibly subclass of the repo)
class filteredrepo(repoview.repoview, self.unfiltered().__class__):
pass
return filteredrepo(self, name)
More information about the Mercurial-devel
mailing list