Mercurial > hg-stable
changeset 34619:18309380fb88
scmutil: factor out transaction name lookup in registersummarycallback()
Add an inner txmatch function in registersummarycallback() factoring out the
logic to determine if the transaction matches a particular sources set. We'll
reuse this function to add some new report logic in the new changeset.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Sun, 01 Oct 2017 09:52:44 +0200 |
parents | 37b4375b1221 |
children | b799f11644d8 |
files | mercurial/scmutil.py |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/scmutil.py Wed Oct 11 05:23:45 2017 +0200 +++ b/mercurial/scmutil.py Sun Oct 01 09:52:44 2017 +0200 @@ -1203,15 +1203,16 @@ def registersummarycallback(repo, otr, txnname=''): """register a callback to issue a summary after the transaction is closed """ - for source in _reportobsoletedsource: - if txnname.startswith(source): - reporef = weakref.ref(repo) - def reportsummary(tr): - """the actual callback reporting the summary""" - repo = reporef() - obsoleted = obsutil.getobsoleted(repo, tr) - if obsoleted: - repo.ui.status(_('obsoleted %i changesets\n') - % len(obsoleted)) - otr.addpostclose('00-txnreport', reportsummary) - break + def txmatch(sources): + return any(txnname.startswith(source) for source in sources) + + if txmatch(_reportobsoletedsource): + reporef = weakref.ref(repo) + def reportsummary(tr): + """the actual callback reporting the summary""" + repo = reporef() + obsoleted = obsutil.getobsoleted(repo, tr) + if obsoleted: + repo.ui.status(_('obsoleted %i changesets\n') + % len(obsoleted)) + otr.addpostclose('00-txnreport', reportsummary)