Patchwork D3734: scmutil: move construction of instability count message to separate fn

login
register
mail settings
Submitter phabricator
Date June 14, 2018, 7:56 p.m.
Message ID <differential-rev-PHID-DREV-5tzx3m4kqj2tgueyijft-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32141/
State Superseded
Headers show

Comments

phabricator - June 14, 2018, 7:56 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3734

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - June 15, 2018, 7:54 a.m.
lothiraldan accepted this revision.
lothiraldan added inline comments.

INLINE COMMENTS

> scmutil.py:1506
> +
> +    exists as a seprate function so that extension can wrap to show more
> +    information like how to fix instabilities"""

Small typo `seprate` -> `separate`

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3734

To: pulkit, #hg-reviewers, lothiraldan
Cc: lothiraldan, mercurial-devel

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1456,9 +1456,9 @@ 
             for instability, revset in instabilitytypes:
                 delta = (newinstabilitycounts[instability] -
                          oldinstabilitycounts[instability])
-                if delta > 0:
-                    repo.ui.warn(_('%i new %s changesets\n') %
-                                 (delta, instability))
+                msg = getinstabilitymessage(delta, instability)
+                if msg:
+                    repo.ui.warn(msg)
 
     if txmatch(_reportnewcssource):
         @reportsummary
@@ -1500,6 +1500,10 @@ 
             repo.ui.status(_('%d local changesets published\n')
                            % len(published))
 
+def getinstabilitymessage(delta, instability):
+    if delta > 0:
+        return _('%i new %s changesets\n') % (delta, instability)
+
 def nodesummaries(repo, nodes, maxnumnodes=4):
     if len(nodes) <= maxnumnodes or repo.ui.verbose:
         return ' '.join(short(h) for h in nodes)