comparison mercurial/scmutil.py @ 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 6fad8059a970
children b799f11644d8
comparison
equal deleted inserted replaced
34618:37b4375b1221 34619:18309380fb88
1201 ] 1201 ]
1202 1202
1203 def registersummarycallback(repo, otr, txnname=''): 1203 def registersummarycallback(repo, otr, txnname=''):
1204 """register a callback to issue a summary after the transaction is closed 1204 """register a callback to issue a summary after the transaction is closed
1205 """ 1205 """
1206 for source in _reportobsoletedsource: 1206 def txmatch(sources):
1207 if txnname.startswith(source): 1207 return any(txnname.startswith(source) for source in sources)
1208 reporef = weakref.ref(repo) 1208
1209 def reportsummary(tr): 1209 if txmatch(_reportobsoletedsource):
1210 """the actual callback reporting the summary""" 1210 reporef = weakref.ref(repo)
1211 repo = reporef() 1211 def reportsummary(tr):
1212 obsoleted = obsutil.getobsoleted(repo, tr) 1212 """the actual callback reporting the summary"""
1213 if obsoleted: 1213 repo = reporef()
1214 repo.ui.status(_('obsoleted %i changesets\n') 1214 obsoleted = obsutil.getobsoleted(repo, tr)
1215 % len(obsoleted)) 1215 if obsoleted:
1216 otr.addpostclose('00-txnreport', reportsummary) 1216 repo.ui.status(_('obsoleted %i changesets\n')
1217 break 1217 % len(obsoleted))
1218 otr.addpostclose('00-txnreport', reportsummary)