##// END OF EJS Templates
summary: augment output with info from extensions
Bryan O'Sullivan -
r19211:3bfd7f1e default
parent child Browse files
Show More
@@ -2082,3 +2082,6 b' def command(table):'
2082 return decorator
2082 return decorator
2083
2083
2084 return cmd
2084 return cmd
2085
2086 # a list of (ui, repo) functions called by commands.summary
2087 summaryhooks = util.hooks()
@@ -5489,6 +5489,8 b' def summary(ui, repo, **opts):'
5489 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5489 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5490 (new, len(bheads)))
5490 (new, len(bheads)))
5491
5491
5492 cmdutil.summaryhooks(ui, repo)
5493
5492 if opts.get('remote'):
5494 if opts.get('remote'):
5493 t = []
5495 t = []
5494 source, branches = hg.parseurl(ui.expandpath('default'))
5496 source, branches = hg.parseurl(ui.expandpath('default'))
@@ -1946,3 +1946,19 b' def sizetoint(s):'
1946 return int(t)
1946 return int(t)
1947 except ValueError:
1947 except ValueError:
1948 raise error.ParseError(_("couldn't parse size: %s") % s)
1948 raise error.ParseError(_("couldn't parse size: %s") % s)
1949
1950 class hooks(object):
1951 '''A collection of hook functions that can be used to extend a
1952 function's behaviour. Hooks are called in lexicographic order,
1953 based on the names of their sources.'''
1954
1955 def __init__(self):
1956 self._hooks = []
1957
1958 def add(self, source, hook):
1959 self._hooks.append((source, hook))
1960
1961 def __call__(self, *args):
1962 self._hooks.sort(key=lambda x: x[0])
1963 for source, hook in self._hooks:
1964 hook(*args)
General Comments 0
You need to be logged in to leave comments. Login now