Patchwork D3830: rebase: suppress transaction warns during dry-run

login
register
mail settings
Submitter phabricator
Date June 24, 2018, 9:31 a.m.
Message ID <differential-rev-PHID-DREV-rx52ug5fseejrl6cfvyx-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32397/
State New
Headers show

Comments

phabricator - June 24, 2018, 9:31 a.m.
khanchi97 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Suppressed warnings thrown while aborting a transaction during
  dryrun because these warnings does not sound safe to user.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS




To: khanchi97, #hg-reviewers
Cc: 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
@@ -283,8 +283,6 @@ 
   rebasing 3:055a42cdd887 "d"
   rebasing 4:e860deea161a "e"
   merging e
-  transaction abort!
-  rollback completed
   hit a merge conflict
   $ hg diff
   $ hg status
diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -105,7 +105,7 @@ 
 class transaction(util.transactional):
     def __init__(self, report, opener, vfsmap, journalname, undoname=None,
                  after=None, createmode=None, validator=None, releasefn=None,
-                 checkambigfiles=None, name=r'<unnamed>'):
+                 checkambigfiles=None, name=r'<unnamed>', suppwarns=False):
         """Begin a new transaction
 
         Begins a new transaction that allows rolling back writes in the event of
@@ -133,6 +133,7 @@ 
         self.map = {}
         self.journal = journalname
         self.undoname = undoname
+        self.suppwarns = suppwarns
         self._queue = []
         # A callback to validate transaction content before closing it.
         # should raise exception is anything is wrong.
@@ -570,7 +571,8 @@ 
                     self.opener.unlink(self.journal)
                 return
 
-            self.report(_("transaction abort!\n"))
+            if not self.suppwarns:
+                self.report(_("transaction abort!\n"))
 
             try:
                 for cat in sorted(self._abortcallback):
@@ -580,7 +582,8 @@ 
                 _playback(self.journal, self.report, self.opener, self._vfsmap,
                           self.entries, self._backupentries, False,
                           checkambigfiles=self.checkambigfiles)
-                self.report(_("rollback completed\n"))
+                if not self.suppwarns:
+                    self.report(_("rollback completed\n"))
             except BaseException:
                 self.report(_("rollback failed - please run hg recover\n"))
         finally:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1224,7 +1224,7 @@ 
             return tr
         return None
 
-    def transaction(self, desc, report=None):
+    def transaction(self, desc, report=None, supptrwarns=False):
         if (self.ui.configbool('devel', 'all-warnings')
                 or self.ui.configbool('devel', 'check-locks')):
             if self._currentlock(self._lockref) is None:
@@ -1371,7 +1371,8 @@ 
                                      validator=validate,
                                      releasefn=releasefn,
                                      checkambigfiles=_cachedfiles,
-                                     name=desc)
+                                     name=desc,
+                                     suppwarns=supptrwarns)
         tr.changes['revs'] = xrange(0, 0)
         tr.changes['obsmarkers'] = set()
         tr.changes['phases'] = {}
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -824,7 +824,7 @@ 
             overrides = {('rebase', 'singletransaction'): True}
             with ui.configoverride(overrides, 'rebase'):
                 _origrebase(ui, repo, inmemory=True, leaveunfinished=True,
-                            **opts)
+                            supptrwarns=True, **opts)
         except error.InMemoryMergeConflictsError:
             ui.status(_('hit a merge conflict\n'))
         else:
@@ -847,7 +847,7 @@ 
     else:
         return _origrebase(ui, repo, **opts)
 
-def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, **opts):
+def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, supptrwarns=False, **opts):
     opts = pycompat.byteskwargs(opts)
     rbsrt = rebaseruntime(repo, ui, inmemory, opts)
 
@@ -912,7 +912,7 @@ 
 
         singletr = ui.configbool('rebase', 'singletransaction')
         if singletr:
-            tr = repo.transaction('rebase')
+            tr = repo.transaction('rebase', supptrwarns=supptrwarns)
 
         # If `rebase.singletransaction` is enabled, wrap the entire operation in
         # one transaction here. Otherwise, transactions are obtained when