D3779: histedit: use progress helper

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Jun 18 07:05:15 UTC 2018


martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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,22 +1158,21 @@
         # 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()
             state.parentctxnode = parentctx.node()
             state.replacements.extend(replacement_)
             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"""



To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list