Show More
@@ -561,7 +561,8 b' def wrapdirstate(orig, self):' | |||||
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) | |
@@ -709,21 +710,3 b' def reposetup(ui, repo):' | |||||
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)) |
|
@@ -308,6 +308,25 b' def wrapcommand(table, command, wrapper,' | |||||
308 | table[key] = tuple(newentry) |
|
308 | table[key] = tuple(newentry) | |
309 | return entry |
|
309 | return entry | |
310 |
|
310 | |||
|
311 | def wrapfilecache(cls, propname, wrapper): | |||
|
312 | """Wraps a filecache property. | |||
|
313 | ||||
|
314 | These can't be wrapped using the normal wrapfunction. | |||
|
315 | """ | |||
|
316 | assert callable(wrapper) | |||
|
317 | for currcls in cls.__mro__: | |||
|
318 | if propname in currcls.__dict__: | |||
|
319 | origfn = currcls.__dict__[propname].func | |||
|
320 | assert callable(origfn) | |||
|
321 | def wrap(*args, **kwargs): | |||
|
322 | return wrapper(origfn, *args, **kwargs) | |||
|
323 | currcls.__dict__[propname].func = wrap | |||
|
324 | break | |||
|
325 | ||||
|
326 | if currcls is object: | |||
|
327 | raise AttributeError( | |||
|
328 | _("type '%s' has no property '%s'") % (cls, propname)) | |||
|
329 | ||||
311 | def wrapfunction(container, funcname, wrapper): |
|
330 | def wrapfunction(container, funcname, wrapper): | |
312 | '''Wrap the function named funcname in container |
|
331 | '''Wrap the function named funcname in container | |
313 |
|
332 |
General Comments 0
You need to be logged in to leave comments.
Login now