Patchwork [2,of,2] histedit: report planning progress from initialization

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

Comments

timeless - Aug. 24, 2016, 5:31 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1472058857 0
#      Wed Aug 24 17:14:17 2016 +0000
# Node ID d0ec531c3307561e18bb76b7178371e1ababcf5d
# Parent  7b0afc5eacdc0662ed0fcde8eb58c8e599a7f695
# Available At https://bitbucket.org/timeless/mercurial-crew
#              hg pull https://bitbucket.org/timeless/mercurial-crew -r d0ec531c3307
histedit: report planning progress from initialization

This hasn't actually shown up as slow, but it could...
timeless - Aug. 25, 2016, 11:11 a.m.
I've now hit this:

planning [                                                      ]
19/1184 8m45s

So yes, this is a real thing. And yes, it's really as slow as progress
predicts :/

On Wed, Aug 24, 2016 at 1:31 PM, timeless <timeless@fmr.im> wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1472058857 0
> #      Wed Aug 24 17:14:17 2016 +0000
> # Node ID d0ec531c3307561e18bb76b7178371e1ababcf5d
> # Parent  7b0afc5eacdc0662ed0fcde8eb58c8e599a7f695
> # Available At https://bitbucket.org/timeless/mercurial-crew
> #              hg pull https://bitbucket.org/timeless/mercurial-crew -r d0ec531c3307
> histedit: report planning progress from initialization
>
> This hasn't actually shown up as slow, but it could...
>
> diff -r 7b0afc5eacdc -r d0ec531c3307 hgext/histedit.py
> --- a/hgext/histedit.py Wed Aug 24 17:13:48 2016 +0000
> +++ b/hgext/histedit.py Wed Aug 24 17:14:17 2016 +0000
> @@ -347,29 +347,36 @@
>
>          keep = lines[index] == 'True'
>          index += 1
> +        ui = self.repo.ui
>
>          # Rules
>          rules = []
>          rulelen = int(lines[index])
>          index += 1
>          for i in xrange(rulelen):
> +            ui.progress(_("planning"), i, 'task',
> +                        _('changes'), rulelen)
>              ruleaction = lines[index]
>              index += 1
>              rule = lines[index]
>              index += 1
>              rules.append((ruleaction, rule))
> +        ui.progress(_("planning"), None)
>
>          # Replacements
>          replacements = []
>          replacementlen = int(lines[index])
>          index += 1
>          for i in xrange(replacementlen):
> +            ui.progress(_("planning"), i, 'task',
> +                        _('changes'), replacementlen)
>              replacement = lines[index]
>              original = node.bin(replacement[:40])
>              succ = [node.bin(replacement[i:i + 40]) for i in
>                      range(40, len(replacement), 40)]
>              replacements.append((original, succ))
>              index += 1
> +        ui.progress(_("planning"), None)
>
>          backupfile = lines[index]
>          index += 1
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Anton Shestakov - Aug. 25, 2016, 12:07 p.m.
25.08.2016, 02:04, "timeless" <timeless@fmr.im>:
> + ui.progress(_("planning"), i, 'task',
> + _('changes'), rulelen)

> + ui.progress(_("planning"), i, 'task',
> + _('changes'), replacementlen)

Here's the header of progress function for context:

def progress(self, topic, pos, item='', unit='', total=None)

Nit: setting item to just 'task' is not very helpful, because it's meant to show distinct things so that users can understand better where exactly progress is. E.g. when you clone a repo the progress bar after "adding file changes" uses item to show filenames. It would be better to show here node hashes or chosen histedit actions or nothing at all (and save space).
Yuya Nishihara - Aug. 28, 2016, 2:35 p.m.
On Wed, 24 Aug 2016 17:31:19 +0000, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1472058857 0
> #      Wed Aug 24 17:14:17 2016 +0000
> # Node ID d0ec531c3307561e18bb76b7178371e1ababcf5d
> # Parent  7b0afc5eacdc0662ed0fcde8eb58c8e599a7f695
> # Available At https://bitbucket.org/timeless/mercurial-crew
> #              hg pull https://bitbucket.org/timeless/mercurial-crew -r d0ec531c3307
> histedit: report planning progress from initialization
> 
> This hasn't actually shown up as slow, but it could...

I don't think parsing rule lines is slow enough to show progress.

> diff -r 7b0afc5eacdc -r d0ec531c3307 hgext/histedit.py
> --- a/hgext/histedit.py	Wed Aug 24 17:13:48 2016 +0000
> +++ b/hgext/histedit.py	Wed Aug 24 17:14:17 2016 +0000
> @@ -347,29 +347,36 @@
>  
>          keep = lines[index] == 'True'
>          index += 1
> +        ui = self.repo.ui
>  
>          # Rules
>          rules = []
>          rulelen = int(lines[index])
>          index += 1
>          for i in xrange(rulelen):
> +            ui.progress(_("planning"), i, 'task',
> +                        _('changes'), rulelen)
>              ruleaction = lines[index]
>              index += 1
>              rule = lines[index]
>              index += 1
>              rules.append((ruleaction, rule))

Looks like two lines per rule. pos and total would be doubled.

Patch

diff -r 7b0afc5eacdc -r d0ec531c3307 hgext/histedit.py
--- a/hgext/histedit.py	Wed Aug 24 17:13:48 2016 +0000
+++ b/hgext/histedit.py	Wed Aug 24 17:14:17 2016 +0000
@@ -347,29 +347,36 @@ 
 
         keep = lines[index] == 'True'
         index += 1
+        ui = self.repo.ui
 
         # Rules
         rules = []
         rulelen = int(lines[index])
         index += 1
         for i in xrange(rulelen):
+            ui.progress(_("planning"), i, 'task',
+                        _('changes'), rulelen)
             ruleaction = lines[index]
             index += 1
             rule = lines[index]
             index += 1
             rules.append((ruleaction, rule))
+        ui.progress(_("planning"), None)
 
         # Replacements
         replacements = []
         replacementlen = int(lines[index])
         index += 1
         for i in xrange(replacementlen):
+            ui.progress(_("planning"), i, 'task',
+                        _('changes'), replacementlen)
             replacement = lines[index]
             original = node.bin(replacement[:40])
             succ = [node.bin(replacement[i:i + 40]) for i in
                     range(40, len(replacement), 40)]
             replacements.append((original, succ))
             index += 1
+        ui.progress(_("planning"), None)
 
         backupfile = lines[index]
         index += 1