comparison mercurial/util.py @ 21046:cc13addbd62b

util: enable "hooks" to return list of the values returned from each hooks
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 16 Apr 2014 00:37:24 +0900
parents c848bfd02366
children c2262004c2e2
comparison
equal deleted inserted replaced
21045:7f875ed19475 21046:cc13addbd62b
1994 def add(self, source, hook): 1994 def add(self, source, hook):
1995 self._hooks.append((source, hook)) 1995 self._hooks.append((source, hook))
1996 1996
1997 def __call__(self, *args): 1997 def __call__(self, *args):
1998 self._hooks.sort(key=lambda x: x[0]) 1998 self._hooks.sort(key=lambda x: x[0])
1999 results = []
1999 for source, hook in self._hooks: 2000 for source, hook in self._hooks:
2000 hook(*args) 2001 results.append(hook(*args))
2002 return results
2001 2003
2002 def debugstacktrace(msg='stacktrace', skip=0, f=sys.stderr, otherf=sys.stdout): 2004 def debugstacktrace(msg='stacktrace', skip=0, f=sys.stderr, otherf=sys.stdout):
2003 '''Writes a message to f (stderr) with a nicely formatted stacktrace. 2005 '''Writes a message to f (stderr) with a nicely formatted stacktrace.
2004 Skips the 'skip' last entries. By default it will flush stdout first. 2006 Skips the 'skip' last entries. By default it will flush stdout first.
2005 It can be used everywhere and do intentionally not require an ui object. 2007 It can be used everywhere and do intentionally not require an ui object.