Patchwork [2,of,2,convert-git-progress,v2] convert: adjust progress bar for octopus merges (issue4169)

login
register
mail settings
Submitter Augie Fackler
Date March 13, 2015, 2:27 p.m.
Message ID <404cbc6dd7ab6bcc5837.1426256859@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/8049/
State Accepted
Commit 603a8d09e12dfb6b734c7e07f37049e5a83e6dae
Headers show

Comments

Augie Fackler - March 13, 2015, 2:27 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1426210910 14400
#      Thu Mar 12 21:41:50 2015 -0400
# Node ID 404cbc6dd7ab6bcc58373e2866feb472b07bae8a
# Parent  93791c0a65e5c1d1abf68f6750869e80b642a1af
convert: adjust progress bar for octopus merges (issue4169)

For merges, we walk the files N-1 times, where N is the number of
parents. This means that for an octopus merge with 3 parents and 2
changed files, we actually fetch 6 files. This corrects the progress
output of the convert command when such commits are encountered.
Matt Mackall - March 16, 2015, 7:19 p.m.
On Fri, 2015-03-13 at 10:27 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1426210910 14400
> #      Thu Mar 12 21:41:50 2015 -0400
> # Node ID 404cbc6dd7ab6bcc58373e2866feb472b07bae8a
> # Parent  93791c0a65e5c1d1abf68f6750869e80b642a1af
> convert: adjust progress bar for octopus merges (issue4169)

These are queued for default, thanks.

Patch

diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -413,7 +413,15 @@  class converter(object):
             parents = [self.map.get(p, p) for p in parents]
         except KeyError:
             parents = [b[0] for b in pbranches]
-        source = progresssource(self.ui, self.source, len(files))
+        if len(parents) < 3:
+            source = progresssource(self.ui, self.source, len(files))
+        else:
+            # For an octopus merge, we end up traversing the list of
+            # changed files N-1 times. This tweak to the number of
+            # files makes it so the progress bar doesn't overflow
+            # itself.
+            source = progresssource(self.ui, self.source,
+                                    len(files) * (len(parents) - 1))
         newnode = self.dest.putcommit(files, copies, parents, commit,
                                       source, self.map, full)
         source.close()
@@ -531,4 +539,3 @@  def convert(ui, src, dest=None, revmapfi
 
     c = converter(ui, srcc, destc, revmapfile, opts)
     c.convert(sortmode)
-
diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -207,14 +207,14 @@  full conversion
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   converting [======================>                   ] 5/9\r (no-eol) (esc)
-  getting files [========>                              ] 1/4\r (no-eol) (esc)
-  getting files [==================>                    ] 2/4\r (no-eol) (esc)
-  getting files [============================>          ] 3/4\r (no-eol) (esc)
-  getting files [======================================>] 4/4\r (no-eol) (esc)
-  getting files [ <=>                                   ] 5/4\r (no-eol) (esc)
-  getting files [  <=>                                  ] 6/4\r (no-eol) (esc)
-  getting files [   <=>                                 ] 7/4\r (no-eol) (esc)
-  getting files [    <=>                                ] 8/4\r (no-eol) (esc)
+  getting files [===>                                   ] 1/8\r (no-eol) (esc)
+  getting files [========>                              ] 2/8\r (no-eol) (esc)
+  getting files [=============>                         ] 3/8\r (no-eol) (esc)
+  getting files [==================>                    ] 4/8\r (no-eol) (esc)
+  getting files [=======================>               ] 5/8\r (no-eol) (esc)
+  getting files [============================>          ] 6/8\r (no-eol) (esc)
+  getting files [=================================>     ] 7/8\r (no-eol) (esc)
+  getting files [======================================>] 8/8\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   converting [===========================>              ] 6/9\r (no-eol) (esc)