changeset 24276:2720f967a7b1

largefiles: replace manifestdict.__contains__, don't extend class We're soon going to add an alternative manifest class (treemanifest). Rather than extending both those classes by largesfiles versions, let's replace the method on the manifest instances.
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 09 Mar 2015 17:13:22 -0700
parents e1cb460a3524
children 22d560fe1516
files hgext/largefiles/reposetup.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/reposetup.py	Sun Mar 08 16:50:57 2015 -0400
+++ b/hgext/largefiles/reposetup.py	Mon Mar 09 17:13:22 2015 -0700
@@ -10,7 +10,7 @@
 import copy
 import os
 
-from mercurial import error, manifest, match as match_, util
+from mercurial import error, match as match_, util
 from mercurial.i18n import _
 from mercurial import scmutil, localrepo
 
@@ -38,17 +38,17 @@
         def __getitem__(self, changeid):
             ctx = super(lfilesrepo, self).__getitem__(changeid)
             if self.lfstatus:
-                class lfilesmanifestdict(manifest.manifestdict):
-                    def __contains__(self, filename):
-                        orig = super(lfilesmanifestdict, self).__contains__
-                        return orig(filename) or orig(lfutil.standin(filename))
                 class lfilesctx(ctx.__class__):
                     def files(self):
                         filenames = super(lfilesctx, self).files()
                         return [lfutil.splitstandin(f) or f for f in filenames]
                     def manifest(self):
                         man1 = super(lfilesctx, self).manifest()
-                        man1.__class__ = lfilesmanifestdict
+                        orig = man1.__contains__
+                        def __contains__(self, filename):
+                            return (orig(filename) or
+                                    orig(lfutil.standin(filename)))
+                        man1.__contains__ = __contains__.__get__(man1)
                         return man1
                     def filectx(self, path, fileid=None, filelog=None):
                         orig = super(lfilesctx, self).filectx