largefiles: don't create chain of __contains__ calls
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 11 Mar 2015 21:36:48 -0700
changeset 24287 f78252429e0a
parent 24286 40528ad1b1e8
child 24288 922e087ba158
largefiles: don't create chain of __contains__ calls Matt Harbison pointed out that my recent 2720f967a7b1 might cause __contains__ to continously get replaced by another version that calls itself, since the manifest instance returned by the super method is always the same instance due to @propertycache. He also suggested replacing the class instead, as is done with the context class in the surrounding code. Do so.
hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py	Thu Mar 12 09:06:45 2015 -0700
+++ b/hgext/largefiles/reposetup.py	Wed Mar 11 21:36:48 2015 -0700
@@ -44,11 +44,12 @@
                         return [lfutil.splitstandin(f) or f for f in filenames]
                     def manifest(self):
                         man1 = super(lfilesctx, self).manifest()
-                        orig = man1.__contains__
-                        def __contains__(self, filename):
-                            return (orig(filename) or
-                                    orig(lfutil.standin(filename)))
-                        man1.__contains__ = __contains__.__get__(man1)
+                        class lfilesmanifest(man1.__class):
+                            def __contains__(self, filename):
+                                orig = super(lfilesmanifest, self).__contains__
+                                return (orig(filename) or
+                                        orig(lfutil.standin(filename)))
+                        man1.__class__ = lfilesmanifest
                         return man1
                     def filectx(self, path, fileid=None, filelog=None):
                         orig = super(lfilesctx, self).filectx