##// END OF EJS Templates
largefiles: avoid dynamically subclassing context instances...
Martin von Zweigbergk -
r43986:7f4d58c2 default
parent child Browse files
Show More
@@ -15,6 +15,7 b' from mercurial.i18n import _'
15 15
16 16 from mercurial import (
17 17 error,
18 extensions,
18 19 localrepo,
19 20 match as matchmod,
20 21 scmutil,
@@ -47,45 +48,46 b' def reposetup(ui, repo):'
47 48 ctx = super(lfilesrepo, self).__getitem__(changeid)
48 49 if self.lfstatus:
49 50
50 class lfilesctx(ctx.__class__):
51 def files(self):
52 filenames = super(lfilesctx, self).files()
53 return [lfutil.splitstandin(f) or f for f in filenames]
51 def files(orig):
52 filenames = orig()
53 return [lfutil.splitstandin(f) or f for f in filenames]
54 54
55 def manifest(self):
56 man1 = super(lfilesctx, self).manifest()
55 extensions.wrapfunction(ctx, 'files', files)
56
57 def manifest(orig):
58 man1 = orig()
57 59
58 class lfilesmanifest(man1.__class__):
59 def __contains__(self, filename):
60 orig = super(lfilesmanifest, self).__contains__
61 return orig(filename) or orig(
62 lfutil.standin(filename)
63 )
60 class lfilesmanifest(man1.__class__):
61 def __contains__(self, filename):
62 orig = super(lfilesmanifest, self).__contains__
63 return orig(filename) or orig(
64 lfutil.standin(filename)
65 )
64 66
65 man1.__class__ = lfilesmanifest
66 return man1
67 man1.__class__ = lfilesmanifest
68 return man1
67 69
68 def filectx(self, path, fileid=None, filelog=None):
69 orig = super(lfilesctx, self).filectx
70 try:
71 if filelog is not None:
72 result = orig(path, fileid, filelog)
73 else:
74 result = orig(path, fileid)
75 except error.LookupError:
76 # Adding a null character will cause Mercurial to
77 # identify this as a binary file.
78 if filelog is not None:
79 result = orig(
80 lfutil.standin(path), fileid, filelog
81 )
82 else:
83 result = orig(lfutil.standin(path), fileid)
84 olddata = result.data
85 result.data = lambda: olddata() + b'\0'
86 return result
70 extensions.wrapfunction(ctx, 'manifest', manifest)
87 71
88 ctx.__class__ = lfilesctx
72 def filectx(orig, path, fileid=None, filelog=None):
73 try:
74 if filelog is not None:
75 result = orig(path, fileid, filelog)
76 else:
77 result = orig(path, fileid)
78 except error.LookupError:
79 # Adding a null character will cause Mercurial to
80 # identify this as a binary file.
81 if filelog is not None:
82 result = orig(lfutil.standin(path), fileid, filelog)
83 else:
84 result = orig(lfutil.standin(path), fileid)
85 olddata = result.data
86 result.data = lambda: olddata() + b'\0'
87 return result
88
89 extensions.wrapfunction(ctx, 'filectx', filectx)
90
89 91 return ctx
90 92
91 93 # Figure out the status of big files and insert them into the
General Comments 0
You need to be logged in to leave comments. Login now