changeset 38378:e5d87c69bbcb

histedit: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3779
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 17 Jun 2018 22:05:54 -0700
parents a73eab7d6575
children 3a7c33a2cc5e
files hgext/histedit.py
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Sun Jun 17 22:01:59 2018 -0700
+++ b/hgext/histedit.py	Sun Jun 17 22:05:54 2018 -0700
@@ -1149,8 +1149,6 @@
     # even if there's an exception before the first transaction serialize.
     state.write()
 
-    total = len(state.actions)
-    pos = 0
     tr = None
     # Don't use singletransaction by default since it rolls the entire
     # transaction back if an unexpected exception happens (like a
@@ -1160,13 +1158,13 @@
         # and reopen a transaction. For example, if the action executes an
         # external process it may choose to commit the transaction first.
         tr = repo.transaction('histedit')
-    with util.acceptintervention(tr):
+    progress = ui.makeprogress(_("editing"), unit=_('changes'),
+                               total=len(state.actions))
+    with progress, util.acceptintervention(tr):
         while state.actions:
             state.write(tr=tr)
             actobj = state.actions[0]
-            pos += 1
-            ui.progress(_("editing"), pos, actobj.torule(),
-                        _('changes'), total)
+            progress.increment(item=actobj.torule())
             ui.debug('histedit: processing %s %s\n' % (actobj.verb,\
                                                        actobj.torule()))
             parentctx, replacement_ = actobj.run()
@@ -1175,7 +1173,6 @@
             state.actions.pop(0)
 
     state.write()
-    ui.progress(_("editing"), None)
 
 def _finishhistedit(ui, repo, state, fm):
     """This action runs when histedit is finishing its session"""