Patchwork [1,of,2] histedit: report progress from verifyactions (issue5341)

login
register
mail settings
Submitter timeless
Date Aug. 24, 2016, 5:31 p.m.
Message ID <7b0afc5eacdc0662ed0f.1472059878@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/16400/
State Changes Requested
Headers show

Comments

timeless - Aug. 24, 2016, 5:31 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1472058828 0
#      Wed Aug 24 17:13:48 2016 +0000
# Node ID 7b0afc5eacdc0662ed0fcde8eb58c8e599a7f695
# Parent  b1809f5d7630a3fff0fa715bbd30dba0f07672a8
# Available At https://bitbucket.org/timeless/mercurial-crew
#              hg pull https://bitbucket.org/timeless/mercurial-crew -r 7b0afc5eacdc
histedit: report progress from verifyactions (issue5341)

With this change, I get progress like this:
checking [==>                                                         ]  39/726 5m01s

And sadly, those time estimates are accurate.
The verifyactions step is *much* slower than the editing stage:
editing [===>                                                         ]  49/726 1m47s
Yuya Nishihara - Aug. 28, 2016, 2:28 p.m.
On Wed, 24 Aug 2016 17:31:18 +0000, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1472058828 0
> #      Wed Aug 24 17:13:48 2016 +0000
> # Node ID 7b0afc5eacdc0662ed0fcde8eb58c8e599a7f695
> # Parent  b1809f5d7630a3fff0fa715bbd30dba0f07672a8
> # Available At https://bitbucket.org/timeless/mercurial-crew
> #              hg pull https://bitbucket.org/timeless/mercurial-crew -r 7b0afc5eacdc
> histedit: report progress from verifyactions (issue5341)
> 
> With this change, I get progress like this:
> checking [==>                                                         ]  39/726 5m01s
> 
> And sadly, those time estimates are accurate.
> The verifyactions step is *much* slower than the editing stage:
> editing [===>                                                         ]  49/726 1m47s
> 
> diff -r b1809f5d7630 -r 7b0afc5eacdc hgext/histedit.py

> @@ -1399,7 +1399,12 @@
>      expected = set(c.hex() for c in ctxs)
>      seen = set()
>      prev = None
> +    rulelen = len(actions)
> +    i = 0
>      for action in actions:
> +        i += 1

could be "for i, aciton in enumerate(actions)"

> +        ui.progress(_("checking"), i, 'task',
> +                    _('changes'), rulelen)

As Anton said, item='task' is useless and should be omitted.

Patch

diff -r b1809f5d7630 -r 7b0afc5eacdc hgext/histedit.py
--- a/hgext/histedit.py	Mon Aug 15 20:39:33 2016 -0700
+++ b/hgext/histedit.py	Wed Aug 24 17:13:48 2016 +0000
@@ -1382,14 +1382,14 @@ 
 
 def warnverifyactions(ui, repo, actions, state, ctxs):
     try:
-        verifyactions(actions, state, ctxs)
+        verifyactions(ui, actions, state, ctxs)
     except error.ParseError:
         if repo.vfs.exists('histedit-last-edit.txt'):
             ui.warn(_('warning: histedit rules saved '
                       'to: .hg/histedit-last-edit.txt\n'))
         raise
 
-def verifyactions(actions, state, ctxs):
+def verifyactions(ui, actions, state, ctxs):
     """Verify that there exists exactly one action per given changeset and
     other constraints.
 
@@ -1399,7 +1399,12 @@ 
     expected = set(c.hex() for c in ctxs)
     seen = set()
     prev = None
+    rulelen = len(actions)
+    i = 0
     for action in actions:
+        i += 1
+        ui.progress(_("checking"), i, 'task',
+                    _('changes'), rulelen)
         action.verify(prev)
         prev = action
         constraints = action.constraints()
@@ -1426,6 +1431,7 @@ 
                         'duplicated command for changeset %s') %
                         ha[:12])
             seen.add(ha)
+    ui.progress(_("checking"), None)
     missing = sorted(expected - seen)  # sort to stabilize output
 
     if state.repo.ui.configbool('histedit', 'dropmissing'):