Patchwork D3779: histedit: use progress helper

login
register
mail settings
Submitter phabricator
Date June 18, 2018, 7:05 a.m.
Message ID <differential-rev-PHID-DREV-vrkfku3n6li2jdmc4dqo-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32239/
State Superseded
Headers show

Comments

phabricator - June 18, 2018, 7:05 a.m.
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




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

Patch

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"""