##// 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 from mercurial import (
16 from mercurial import (
17 error,
17 error,
18 extensions,
18 localrepo,
19 localrepo,
19 match as matchmod,
20 match as matchmod,
20 scmutil,
21 scmutil,
@@ -47,13 +48,14 b' def reposetup(ui, repo):'
47 ctx = super(lfilesrepo, self).__getitem__(changeid)
48 ctx = super(lfilesrepo, self).__getitem__(changeid)
48 if self.lfstatus:
49 if self.lfstatus:
49
50
50 class lfilesctx(ctx.__class__):
51 def files(orig):
51 def files(self):
52 filenames = orig()
52 filenames = super(lfilesctx, self).files()
53 return [lfutil.splitstandin(f) or f for f in filenames]
53 return [lfutil.splitstandin(f) or f for f in filenames]
54
54
55 def manifest(self):
55 extensions.wrapfunction(ctx, 'files', files)
56 man1 = super(lfilesctx, self).manifest()
56
57 def manifest(orig):
58 man1 = orig()
57
59
58 class lfilesmanifest(man1.__class__):
60 class lfilesmanifest(man1.__class__):
59 def __contains__(self, filename):
61 def __contains__(self, filename):
@@ -65,8 +67,9 b' def reposetup(ui, repo):'
65 man1.__class__ = lfilesmanifest
67 man1.__class__ = lfilesmanifest
66 return man1
68 return man1
67
69
68 def filectx(self, path, fileid=None, filelog=None):
70 extensions.wrapfunction(ctx, 'manifest', manifest)
69 orig = super(lfilesctx, self).filectx
71
72 def filectx(orig, path, fileid=None, filelog=None):
70 try:
73 try:
71 if filelog is not None:
74 if filelog is not None:
72 result = orig(path, fileid, filelog)
75 result = orig(path, fileid, filelog)
@@ -76,16 +79,15 b' def reposetup(ui, repo):'
76 # Adding a null character will cause Mercurial to
79 # Adding a null character will cause Mercurial to
77 # identify this as a binary file.
80 # identify this as a binary file.
78 if filelog is not None:
81 if filelog is not None:
79 result = orig(
82 result = orig(lfutil.standin(path), fileid, filelog)
80 lfutil.standin(path), fileid, filelog
81 )
82 else:
83 else:
83 result = orig(lfutil.standin(path), fileid)
84 result = orig(lfutil.standin(path), fileid)
84 olddata = result.data
85 olddata = result.data
85 result.data = lambda: olddata() + b'\0'
86 result.data = lambda: olddata() + b'\0'
86 return result
87 return result
87
88
88 ctx.__class__ = lfilesctx
89 extensions.wrapfunction(ctx, 'filectx', filectx)
90
89 return ctx
91 return ctx
90
92
91 # Figure out the status of big files and insert them into the
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