Mercurial > hg
changeset 34620:b799f11644d8
scmutil: factor out building of transaction summary callback
In registersummarycallback(), we extra generic bits of the existing
"reportsummary" function into a decorator which will be used in forthcoming
changesets to add new summary callbacks.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Wed, 04 Oct 2017 18:49:09 +0200 |
parents | 18309380fb88 |
children | 5613fb1583d6 |
files | mercurial/scmutil.py |
diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/scmutil.py Sun Oct 01 09:52:44 2017 +0200 +++ b/mercurial/scmutil.py Wed Oct 04 18:49:09 2017 +0200 @@ -1206,13 +1206,23 @@ def txmatch(sources): return any(txnname.startswith(source) for source in sources) - if txmatch(_reportobsoletedsource): + categories = [] + + def reportsummary(func): + """decorator for report callbacks.""" reporef = weakref.ref(repo) - def reportsummary(tr): - """the actual callback reporting the summary""" + def wrapped(tr): repo = reporef() + func(repo, tr) + newcat = '%2i-txnreport' % len(categories) + otr.addpostclose(newcat, wrapped) + categories.append(newcat) + return wrapped + + if txmatch(_reportobsoletedsource): + @reportsummary + def reportobsoleted(repo, tr): obsoleted = obsutil.getobsoleted(repo, tr) if obsoleted: repo.ui.status(_('obsoleted %i changesets\n') % len(obsoleted)) - otr.addpostclose('00-txnreport', reportsummary)