comparison hgext/largefiles/reposetup.py @ 22517:e54a001ace06

largefiles: extract 'orig' method in lfilesctx.filectx
author Martin von Zweigbergk <martinvonz@gmail.com>
date Tue, 16 Sep 2014 14:51:25 -0700
parents 5e27eccbc0a4
children 52dd6e25121f
comparison
equal deleted inserted replaced
22516:5e27eccbc0a4 22517:e54a001ace06
46 def manifest(self): 46 def manifest(self):
47 man1 = super(lfilesctx, self).manifest() 47 man1 = super(lfilesctx, self).manifest()
48 man1.__class__ = lfilesmanifestdict 48 man1.__class__ = lfilesmanifestdict
49 return man1 49 return man1
50 def filectx(self, path, fileid=None, filelog=None): 50 def filectx(self, path, fileid=None, filelog=None):
51 orig = super(lfilesctx, self).filectx
51 try: 52 try:
52 if filelog is not None: 53 if filelog is not None:
53 result = super(lfilesctx, self).filectx( 54 result = orig(path, fileid, filelog)
54 path, fileid, filelog)
55 else: 55 else:
56 result = super(lfilesctx, self).filectx( 56 result = orig(path, fileid)
57 path, fileid)
58 except error.LookupError: 57 except error.LookupError:
59 # Adding a null character will cause Mercurial to 58 # Adding a null character will cause Mercurial to
60 # identify this as a binary file. 59 # identify this as a binary file.
61 if filelog is not None: 60 if filelog is not None:
62 result = super(lfilesctx, self).filectx( 61 result = orig(lfutil.standin(path), fileid,
63 lfutil.standin(path), fileid, filelog) 62 filelog)
64 else: 63 else:
65 result = super(lfilesctx, self).filectx( 64 result = orig(lfutil.standin(path), fileid)
66 lfutil.standin(path), fileid)
67 olddata = result.data 65 olddata = result.data
68 result.data = lambda: olddata() + '\0' 66 result.data = lambda: olddata() + '\0'
69 return result 67 return result
70 ctx.__class__ = lfilesctx 68 ctx.__class__ = lfilesctx
71 return ctx 69 return ctx