comparison mercurial/scmutil.py @ 33541:b47fef6d2365

transaction-summary: display the summary for all transactions Now that we records "all" changes happening in a transaction (in tr.changes) we will be able to provide better report on various changes (phases turned public, changeset obsoleted, branch merged or created, etc..) This is far too late in the cycle to play with this, but having this existing method called more widely will help extensions to play around with various options during the 4.4 cycle. Instead of calling registersummarycallback only for transactions we want, we always call it and use the transaction name to decide when to report (eg: we do not want `hg amend` to report new obsoleted changesets). Filtering on transaction name does not seems great, but seems good enough for the moment. We can change the API during the next cycle. The previous manual call during unbundling of the bundle2 "obsmarkers" part is no longer necessary and has been dropped.
author Boris Feld <boris.feld@octobus.net>
date Sun, 16 Jul 2017 02:20:06 +0200
parents 9689239d7c2b
children b11e8c67fb0f
comparison
equal deleted inserted replaced
33540:e07c5740eaaa 33541:b47fef6d2365
1078 raise error.ProgrammingError(e) 1078 raise error.ProgrammingError(e)
1079 lines.append("%s=%s\n" % (k, v)) 1079 lines.append("%s=%s\n" % (k, v))
1080 with self.vfs(self.path, mode='wb', atomictemp=True) as fp: 1080 with self.vfs(self.path, mode='wb', atomictemp=True) as fp:
1081 fp.write(''.join(lines)) 1081 fp.write(''.join(lines))
1082 1082
1083 def registersummarycallback(repo, otr): 1083 _reportobsoletedsource = [
1084 'pull',
1085 'push',
1086 'serve',
1087 'unbundle',
1088 ]
1089
1090 def registersummarycallback(repo, otr, txnname=''):
1084 """register a callback to issue a summary after the transaction is closed 1091 """register a callback to issue a summary after the transaction is closed
1085 """ 1092 """
1086 reporef = weakref.ref(repo) 1093 for source in _reportobsoletedsource:
1087 def reportsummary(tr): 1094 if txnname.startswith(source):
1088 """the actual callback reporting the summary""" 1095 reporef = weakref.ref(repo)
1089 repo = reporef() 1096 def reportsummary(tr):
1090 obsoleted = obsutil.getobsoleted(repo, tr) 1097 """the actual callback reporting the summary"""
1091 if obsoleted: 1098 repo = reporef()
1092 repo.ui.status(_('obsoleted %i changesets\n') % len(obsoleted)) 1099 obsoleted = obsutil.getobsoleted(repo, tr)
1093 otr.addpostclose('00-txnreport', reportsummary) 1100 if obsoleted:
1101 repo.ui.status(_('obsoleted %i changesets\n')
1102 % len(obsoleted))
1103 otr.addpostclose('00-txnreport', reportsummary)
1104 break