changeset 24328:603a8d09e12d

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.
author Augie Fackler <augie@google.com>
date Thu, 12 Mar 2015 21:41:50 -0400
parents f7c0556d22d7
children e7ca4d4b10e1
files hgext/convert/convcmd.py tests/test-convert-git.t
diffstat 2 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/convcmd.py	Thu Mar 12 21:31:52 2015 -0400
+++ b/hgext/convert/convcmd.py	Thu Mar 12 21:41:50 2015 -0400
@@ -413,7 +413,15 @@
             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()
@@ -535,4 +543,3 @@
 
     c = converter(ui, srcc, destc, revmapfile, opts)
     c.convert(sortmode)
-
--- a/tests/test-convert-git.t	Thu Mar 12 21:31:52 2015 -0400
+++ b/tests/test-convert-git.t	Thu Mar 12 21:41:50 2015 -0400
@@ -207,14 +207,14 @@
                                                               \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)