comparison mercurial/scmutil.py @ 35709:1a09dad8b85a

evolution: report new unstable changesets This adds a transaction summary callback that reports the number of new orphan, content-divergent and phase-divergent changesets. The code for reporting it is based on the code from the evolve extension, but simplified a bit. It simply counts the numbers for each kind of instability before and after the transaction. That's obviously not very efficient, but it's easy to reason about, so I'm doing this as a first step that can make us quite confident about the test case changes. We can optimize it later and make sure that the tests are not affected. The code has been used in the evolve extension for a long time and has apparently been sufficiently fast, so it doesn't seem like a pressing issue. Unlike the evolve extension's version of this report, this version applies to all commands (or all transactions run as part of any command, to be exact). Differential Revision: https://phab.mercurial-scm.org/D1867
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 14 Jan 2018 23:59:17 -0800
parents b55a142f00c5
children 5cd60b0587a8
comparison
equal deleted inserted replaced
35708:03e921942163 35709:1a09dad8b85a
1220 _reportnewcssource = [ 1220 _reportnewcssource = [
1221 'pull', 1221 'pull',
1222 'unbundle', 1222 'unbundle',
1223 ] 1223 ]
1224 1224
1225 # A marker that tells the evolve extension to suppress its own reporting
1226 _reportstroubledchangesets = True
1227
1225 def registersummarycallback(repo, otr, txnname=''): 1228 def registersummarycallback(repo, otr, txnname=''):
1226 """register a callback to issue a summary after the transaction is closed 1229 """register a callback to issue a summary after the transaction is closed
1227 """ 1230 """
1228 def txmatch(sources): 1231 def txmatch(sources):
1229 return any(txnname.startswith(source) for source in sources) 1232 return any(txnname.startswith(source) for source in sources)
1254 def reportobsoleted(repo, tr): 1257 def reportobsoleted(repo, tr):
1255 obsoleted = obsutil.getobsoleted(repo, tr) 1258 obsoleted = obsutil.getobsoleted(repo, tr)
1256 if obsoleted: 1259 if obsoleted:
1257 repo.ui.status(_('obsoleted %i changesets\n') 1260 repo.ui.status(_('obsoleted %i changesets\n')
1258 % len(obsoleted)) 1261 % len(obsoleted))
1262
1263 if obsolete.isenabled(repo, obsolete.createmarkersopt):
1264 instabilitytypes = [
1265 ('orphan', 'orphan'),
1266 ('phase-divergent', 'phasedivergent'),
1267 ('content-divergent', 'contentdivergent'),
1268 ]
1269
1270 def getinstabilitycounts(repo):
1271 filtered = repo.changelog.filteredrevs
1272 counts = {}
1273 for instability, revset in instabilitytypes:
1274 counts[instability] = len(set(obsolete.getrevs(repo, revset)) -
1275 filtered)
1276 return counts
1277
1278 oldinstabilitycounts = getinstabilitycounts(repo)
1279 @reportsummary
1280 def reportnewinstabilities(repo, tr):
1281 newinstabilitycounts = getinstabilitycounts(repo)
1282 for instability, revset in instabilitytypes:
1283 delta = (newinstabilitycounts[instability] -
1284 oldinstabilitycounts[instability])
1285 if delta > 0:
1286 repo.ui.warn(_('%i new %s changesets\n') %
1287 (delta, instability))
1259 1288
1260 if txmatch(_reportnewcssource): 1289 if txmatch(_reportnewcssource):
1261 @reportsummary 1290 @reportsummary
1262 def reportnewcs(repo, tr): 1291 def reportnewcs(repo, tr):
1263 """Report the range of new revisions pulled/unbundled.""" 1292 """Report the range of new revisions pulled/unbundled."""