mercurial/scmutil.py
changeset 34620 b799f11644d8
parent 34619 18309380fb88
child 34645 75979c8d4572
equal deleted inserted replaced
34619:18309380fb88 34620:b799f11644d8
  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     def txmatch(sources):
  1206     def txmatch(sources):
  1207         return any(txnname.startswith(source) for source in sources)
  1207         return any(txnname.startswith(source) for source in sources)
  1208 
  1208 
       
  1209     categories = []
       
  1210 
       
  1211     def reportsummary(func):
       
  1212         """decorator for report callbacks."""
       
  1213         reporef = weakref.ref(repo)
       
  1214         def wrapped(tr):
       
  1215             repo = reporef()
       
  1216             func(repo, tr)
       
  1217         newcat = '%2i-txnreport' % len(categories)
       
  1218         otr.addpostclose(newcat, wrapped)
       
  1219         categories.append(newcat)
       
  1220         return wrapped
       
  1221 
  1209     if txmatch(_reportobsoletedsource):
  1222     if txmatch(_reportobsoletedsource):
  1210         reporef = weakref.ref(repo)
  1223         @reportsummary
  1211         def reportsummary(tr):
  1224         def reportobsoleted(repo, tr):
  1212             """the actual callback reporting the summary"""
       
  1213             repo = reporef()
       
  1214             obsoleted = obsutil.getobsoleted(repo, tr)
  1225             obsoleted = obsutil.getobsoleted(repo, tr)
  1215             if obsoleted:
  1226             if obsoleted:
  1216                 repo.ui.status(_('obsoleted %i changesets\n')
  1227                 repo.ui.status(_('obsoleted %i changesets\n')
  1217                                % len(obsoleted))
  1228                                % len(obsoleted))
  1218         otr.addpostclose('00-txnreport', reportsummary)