comparison hgext/largefiles/reposetup.py @ 18969:257afe5489d4

largefiles: improve repo wrapping detection Before this patch, repo wrapping detection in "reposetup()" of largefiles can detect only limited repo wrapping: replacing target functions by another one named as "wrap". So, it can't detect repo wrapping even in recommended style: replacing "__class__" of repo by derived class. This patch can detect repo wrapping in both styles below: - replacing "__class__" of repo by derived class (recommended style): class derived(repo.__class__): def push(self, *args, **kwargs): return super(derived, self).push(*args, **kwargs) repo.__class__ = derived - replacing function of repo by another one (not recommended style): orgpush = repo.push def push(*args, **kwargs): return orgpush(*args, **kwargs) repo.push = push
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 10 Apr 2013 02:27:35 +0900
parents c2d079387b2c
children ac41bb76c737
comparison
equal deleted inserted replaced
18968:7d2a7f8e9da4 18969:257afe5489d4
25 # wire repositories should be given new wireproto functions but not the 25 # wire repositories should be given new wireproto functions but not the
26 # other largefiles modifications 26 # other largefiles modifications
27 if not repo.local(): 27 if not repo.local():
28 return proto.wirereposetup(ui, repo) 28 return proto.wirereposetup(ui, repo)
29 29
30 origclass = localrepo.localrepository
31 repoclass = repo.__class__
30 for name in ('status', 'commitctx', 'commit', 'push'): 32 for name in ('status', 'commitctx', 'commit', 'push'):
31 method = getattr(repo, name) 33 if (getattr(origclass, name) != getattr(repoclass, name) or
32 if (isinstance(method, types.FunctionType) and 34 isinstance(getattr(repo, name), types.FunctionType)):
33 method.func_name == 'wrap'):
34 ui.warn(_('largefiles: repo method %r appears to have already been' 35 ui.warn(_('largefiles: repo method %r appears to have already been'
35 ' wrapped by another extension: ' 36 ' wrapped by another extension: '
36 'largefiles may behave incorrectly\n') 37 'largefiles may behave incorrectly\n')
37 % name) 38 % name)
38 39