comparison mercurial/scmutil.py @ 38460:1cac2e8c7624

scmutil: move construction of instability count message to separate fn When the commad we are running, introduces new instabilities, we show a message like `5 new orphan changesets`, `2 new content-divergent changesets`, `1 new phase-divergent changesets` etc which is very nice. Now taking a step ahead, we want users to show how to fix them too. Something like: `5 new orphan changesets (run 'hg evolve' to resolve/stabilize them)` `2 new content-divergent changesets (run 'hg evolve --content-divergent' to resolve them)` and maybe telling user a way to understand more about those new instabilities like `hg evolve --list` or `hg log -r 'orphan()'` something like that. The idea came from issue5855 which I want to fix because fixing that will result in a nice UI. Taking the construction logic out will allow extensions like evolve (maybe rebase too) to wrap that and add information about how to resolve and how to understand the instability more. Differential Revision: https://phab.mercurial-scm.org/D3734
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 15 Jun 2018 00:50:48 +0530
parents 05b7dd11918e
children 077301ac69dc
comparison
equal deleted inserted replaced
38459:d24ad71ff869 38460:1cac2e8c7624
1520 def reportnewinstabilities(repo, tr): 1520 def reportnewinstabilities(repo, tr):
1521 newinstabilitycounts = getinstabilitycounts(repo) 1521 newinstabilitycounts = getinstabilitycounts(repo)
1522 for instability, revset in instabilitytypes: 1522 for instability, revset in instabilitytypes:
1523 delta = (newinstabilitycounts[instability] - 1523 delta = (newinstabilitycounts[instability] -
1524 oldinstabilitycounts[instability]) 1524 oldinstabilitycounts[instability])
1525 if delta > 0: 1525 msg = getinstabilitymessage(delta, instability)
1526 repo.ui.warn(_('%i new %s changesets\n') % 1526 if msg:
1527 (delta, instability)) 1527 repo.ui.warn(msg)
1528 1528
1529 if txmatch(_reportnewcssource): 1529 if txmatch(_reportnewcssource):
1530 @reportsummary 1530 @reportsummary
1531 def reportnewcs(repo, tr): 1531 def reportnewcs(repo, tr):
1532 """Report the range of new revisions pulled/unbundled.""" 1532 """Report the range of new revisions pulled/unbundled."""
1563 ] 1563 ]
1564 if not published: 1564 if not published:
1565 return 1565 return
1566 repo.ui.status(_('%d local changesets published\n') 1566 repo.ui.status(_('%d local changesets published\n')
1567 % len(published)) 1567 % len(published))
1568
1569 def getinstabilitymessage(delta, instability):
1570 """function to return the message to show warning about new instabilities
1571
1572 exists as a separate function so that extension can wrap to show more
1573 information like how to fix instabilities"""
1574 if delta > 0:
1575 return _('%i new %s changesets\n') % (delta, instability)
1568 1576
1569 def nodesummaries(repo, nodes, maxnumnodes=4): 1577 def nodesummaries(repo, nodes, maxnumnodes=4):
1570 if len(nodes) <= maxnumnodes or repo.ui.verbose: 1578 if len(nodes) <= maxnumnodes or repo.ui.verbose:
1571 return ' '.join(short(h) for h in nodes) 1579 return ' '.join(short(h) for h in nodes)
1572 first = ' '.join(short(h) for h in nodes[:maxnumnodes]) 1580 first = ' '.join(short(h) for h in nodes[:maxnumnodes])