[PATCH 2 of 3] localrepo: use type() to create filtered repo type

Gregory Szorc gregory.szorc at gmail.com
Fri May 26 20:42:35 EDT 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1495831746 25200
#      Fri May 26 13:49:06 2017 -0700
# Node ID 9a7f60cb77b6969608d2a9b72a2ccb31a53db82b
# Parent  922d86488388b186fa407eae78fbb811c57a3293
localrepo: use type() to create filtered repo type

This allows us to name the type after the filter. This makes
debugging a bit easier.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -495,9 +495,9 @@ class localrepository(object):
         """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)
+        bases = (repoview.repoview, self.unfiltered().__class__)
+        cls = type('%sfilteredrepo' % name, bases, {})
+        return cls(self, name)
 
     @repofilecache('bookmarks', 'bookmarks.current')
     def _bookmarks(self):


More information about the Mercurial-devel mailing list