Patchwork D3764: rebase: improve output of --dry-run

login
register
mail settings
Submitter phabricator
Date June 24, 2018, 9:30 a.m.
Message ID <bef8e0ad86372bbc84f99115a029e11a@localhost.localdomain>
Download mbox | patch
Permalink /patch/32396/
State Not Applicable
Headers show

Comments

phabricator - June 24, 2018, 9:30 a.m.
khanchi97 updated this revision to Diff 9266.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3764?vs=9264&id=9266

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-inmemory.t

CHANGE DETAILS




To: khanchi97, #hg-reviewers
Cc: indygreg, pulkit, mercurial-devel

Patch

diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
--- a/tests/test-rebase-inmemory.t
+++ b/tests/test-rebase-inmemory.t
@@ -208,11 +208,11 @@ 
 
 Check dryrun gives correct results when there is no conflict in rebasing
   $ hg rebase -s 2 -d 6 -n
+  starting dry-run rebase; repository will not be changed
   rebasing 2:177f92b77385 "c"
   rebasing 3:055a42cdd887 "d"
   rebasing 4:e860deea161a "e"
-  there will be no conflict, you can rebase
-  rebase aborted
+  dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
 
   $ hg diff
   $ hg status
@@ -241,11 +241,11 @@ 
   
 Check dryrun working with --collapse when there is no conflict
   $ hg rebase -s 2 -d 6 -n --collapse
+  starting dry-run rebase; repository will not be changed
   rebasing 2:177f92b77385 "c"
   rebasing 3:055a42cdd887 "d"
   rebasing 4:e860deea161a "e"
-  there will be no conflict, you can rebase
-  rebase aborted
+  dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
 
 Check dryrun gives correct results when there is conflict in rebasing
 Make a conflict:
@@ -278,14 +278,14 @@ 
      a
   
   $ hg rebase -s 2 -d 7 -n
+  starting dry-run rebase; repository will not be changed
   rebasing 2:177f92b77385 "c"
   rebasing 3:055a42cdd887 "d"
   rebasing 4:e860deea161a "e"
   merging e
   transaction abort!
   rollback completed
   hit a merge conflict
-  rebase aborted
   $ hg diff
   $ hg status
   $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
@@ -315,9 +315,9 @@ 
   
 Check dryrun working with --collapse when there is conflicts
   $ hg rebase -s 2 -d 7 -n --collapse
+  starting dry-run rebase; repository will not be changed
   rebasing 2:177f92b77385 "c"
   rebasing 3:055a42cdd887 "d"
   rebasing 4:e860deea161a "e"
   merging e
   hit a merge conflict
-  rebase aborted
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -325,7 +325,7 @@ 
         skippedset.update(obsoleteextinctsuccessors)
         _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset)
 
-    def _prepareabortorcontinue(self, isabort, backup=True):
+    def _prepareabortorcontinue(self, isabort, backup=True, suppwarns=False):
         try:
             self.restorestatus()
             self.collapsemsg = restorecollapsemsg(self.repo, isabort)
@@ -342,7 +342,8 @@ 
                 raise error.Abort(msg, hint=hint)
         if isabort:
             return abort(self.repo, self.originalwd, self.destmap, self.state,
-                         activebookmark=self.activebookmark, backup=backup)
+                         activebookmark=self.activebookmark, backup=backup,
+                         suppwarns=suppwarns)
 
     def _preparenewrebase(self, destmap):
         if not destmap:
@@ -818,15 +819,17 @@ 
         opts[r'dest'] = '_destautoorphanrebase(SRC)'
 
     if dryrun:
+        ui.status(_('starting dry-run rebase; repository will not be changed\n'))
         try:
             overrides = {('rebase', 'singletransaction'): True}
             with ui.configoverride(overrides, 'rebase'):
                 _origrebase(ui, repo, inmemory=True, leaveunfinished=True,
                             **opts)
         except error.InMemoryMergeConflictsError:
             ui.status(_('hit a merge conflict\n'))
         else:
-            ui.status(_('there will be no conflict, you can rebase\n'))
+            ui.status(_('dry-run rebase completed successfully; run without '
+                        '-n/--dry-run to perform this rebase\n'))
         finally:
             _origrebase(ui, repo, inmemory=True, abort=True)
     elif inmemory:
@@ -890,8 +893,11 @@ 
                 mergeutil.checkunresolved(ms)
 
             # If in-memory, means aborting during dry-run, no need to backup
+            # but suppress warnings
             backup = not rbsrt.inmemory
-            retcode = rbsrt._prepareabortorcontinue(abortf, backup=backup)
+            suppwarns = rbsrt.inmemory
+            retcode = rbsrt._prepareabortorcontinue(abortf, backup=backup,
+                                                    suppwarns=suppwarns)
             if retcode is not None:
                 return retcode
         else:
@@ -1545,7 +1551,8 @@ 
 
     return False
 
-def abort(repo, originalwd, destmap, state, activebookmark=None, backup=True):
+def abort(repo, originalwd, destmap, state, activebookmark=None, backup=True,
+          suppwarns=False):
     '''Restore the repository to its original state.  Additional args:
 
     activebookmark: the name of the bookmark that should be active after the
@@ -1598,7 +1605,8 @@ 
     finally:
         clearstatus(repo)
         clearcollapsemsg(repo)
-        repo.ui.warn(_('rebase aborted\n'))
+        if not suppwarns:
+            repo.ui.warn(_('rebase aborted\n'))
     return 0
 
 def sortsource(destmap):