D3830: rebase: suppress transaction warns during dry-run

khanchi97 (Sushil khanchi) phabricator at mercurial-scm.org
Sun Jul 1 09:52:38 UTC 2018


khanchi97 updated this revision to Diff 9384.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3830?vs=9359&id=9384

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

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
@@ -280,8 +280,6 @@
   rebasing 3:055a42cdd887 "d"
   rebasing 4:e860deea161a "e"
   merging e
-  transaction abort!
-  rollback completed
   hit a merge conflict
   [1]
   $ hg diff
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
@@ -843,7 +843,7 @@
             overrides = {('rebase', 'singletransaction'): True}
             with ui.configoverride(overrides, 'rebase'):
                 _origrebase(ui, repo, opts, rbsrt, inmemory=True,
-                            leaveunfinished=True)
+                            leaveunfinished=True, supptrwarns=True)
         except error.InMemoryMergeConflictsError:
             ui.status(_('hit a merge conflict\n'))
             return 1
@@ -859,7 +859,8 @@
     rbsrt = rebaseruntime(repo, ui, inmemory, opts)
     return _origrebase(ui, repo, opts, rbsrt, inmemory=inmemory)
 
-def _origrebase(ui, repo, opts, rbsrt, inmemory=False, leaveunfinished=False):
+def _origrebase(ui, repo, opts, rbsrt, inmemory=False, leaveunfinished=False,
+                supptrwarns=False):
     with repo.wlock(), repo.lock():
         # Validate input and define rebasing points
         destf = opts.get('dest', None)
@@ -916,7 +917,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



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


More information about the Mercurial-devel mailing list