Mercurial > hg
comparison hgext/fsmonitor/__init__.py @ 32722:de09138bf0f5
extensions: move wrapfilecache function from fsmonitor
It makes more sense to put this in core, so other extensions can
trivially get access to it without having to rely on importing
fsmonitor.
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 08 Jun 2017 10:44:53 -0400 |
parents | 952017471f93 |
children | 15e85dded933 |
comparison
equal
deleted
inserted
replaced
32721:c2cb0de25120 | 32722:de09138bf0f5 |
---|---|
559 ds.__class__ = makedirstate(ds.__class__) | 559 ds.__class__ = makedirstate(ds.__class__) |
560 ds._fsmonitorinit(self._fsmonitorstate, self._watchmanclient) | 560 ds._fsmonitorinit(self._fsmonitorstate, self._watchmanclient) |
561 return ds | 561 return ds |
562 | 562 |
563 def extsetup(ui): | 563 def extsetup(ui): |
564 wrapfilecache(localrepo.localrepository, 'dirstate', wrapdirstate) | 564 extensions.wrapfilecache( |
565 localrepo.localrepository, 'dirstate', wrapdirstate) | |
565 if pycompat.sysplatform == 'darwin': | 566 if pycompat.sysplatform == 'darwin': |
566 # An assist for avoiding the dangling-symlink fsevents bug | 567 # An assist for avoiding the dangling-symlink fsevents bug |
567 extensions.wrapfunction(os, 'symlink', wrapsymlink) | 568 extensions.wrapfunction(os, 'symlink', wrapsymlink) |
568 | 569 |
569 extensions.wrapfunction(merge, 'update', wrapupdate) | 570 extensions.wrapfunction(merge, 'update', wrapupdate) |
707 def status(self, *args, **kwargs): | 708 def status(self, *args, **kwargs): |
708 orig = super(fsmonitorrepo, self).status | 709 orig = super(fsmonitorrepo, self).status |
709 return overridestatus(orig, self, *args, **kwargs) | 710 return overridestatus(orig, self, *args, **kwargs) |
710 | 711 |
711 repo.__class__ = fsmonitorrepo | 712 repo.__class__ = fsmonitorrepo |
712 | |
713 def wrapfilecache(cls, propname, wrapper): | |
714 """Wraps a filecache property. These can't be wrapped using the normal | |
715 wrapfunction. This should eventually go into upstream Mercurial. | |
716 """ | |
717 assert callable(wrapper) | |
718 for currcls in cls.__mro__: | |
719 if propname in currcls.__dict__: | |
720 origfn = currcls.__dict__[propname].func | |
721 assert callable(origfn) | |
722 def wrap(*args, **kwargs): | |
723 return wrapper(origfn, *args, **kwargs) | |
724 currcls.__dict__[propname].func = wrap | |
725 break | |
726 | |
727 if currcls is object: | |
728 raise AttributeError( | |
729 _("type '%s' has no property '%s'") % (cls, propname)) |