diff mercurial/localrepo.py @ 18100:3a6ddacb7198

clfilter: add actual repo filtering mechanism We add a `filtered` method on repo. This method return an instance of `repoview` that behaves exactly as the original repository but with a filtered changelog attribute. Filters are identified by a "name". Planned filter are `unserved`, `hidden` and `mutable`. Filtering the repository in place what out of question as it wont not allows multiple thread to share the same repo. It would makes control of the filtering scope harder too. See the `repoview` docstring for details. A mechanism to compute filtered revision is also installed. Some caches will be installed in later commit.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 20 Dec 2012 15:32:42 +0100
parents ff36650e4238
children a464deecc9dd
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Dec 19 16:56:26 2012 -0800
+++ b/mercurial/localrepo.py	Thu Dec 20 15:32:42 2012 +0100
@@ -6,7 +6,7 @@
 # GNU General Public License version 2 or any later version.
 from node import bin, hex, nullid, nullrev, short
 from i18n import _
-import peer, changegroup, subrepo, discovery, pushkey, obsolete
+import peer, changegroup, subrepo, discovery, pushkey, obsolete, repoview
 import changelog, dirstate, filelog, manifest, context, bookmarks, phases
 import lock, transaction, store, encoding, base85
 import scmutil, util, extensions, hook, error, revset
@@ -303,6 +303,14 @@
         Intended to be ovewritten 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
+        # (possibily subclass of the repo)
+        class proxycls(repoview.repoview, self.unfiltered().__class__):
+            pass
+        return proxycls(self, name)
+
     @repofilecache('bookmarks')
     def _bookmarks(self):
         return bookmarks.bmstore(self)