Patchwork [5,of,5] convert: add config option for disabling ancestor parent checks

login
register
mail settings
Submitter Durham Goode
Date June 30, 2015, 1:44 a.m.
Message ID <76aa50d41f2919692a35.1435628645@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/9825/
State Superseded
Headers show

Comments

Durham Goode - June 30, 2015, 1:44 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1435610664 25200
#      Mon Jun 29 13:44:24 2015 -0700
# Node ID 76aa50d41f2919692a3586ba1f45e631d9453918
# Parent  c4c8a8f7781e3eb4d836c13e380155e8c5ebbebe
convert: add config option for disabling ancestor parent checks

When converting merge commits, convert checks if any of the parents are
ancestors of any of the other parents. To do this, it builds an ancestor list
for every commit in the repository. On large repos this can take a long time
(30min+). Let's add an option for disabling this check to preserve performance.

The downside of this is that it may create unnecessary parent connections when
enabled (which is unfortunate, but not incorrect).

To verify, I ran the convert tests with the flag enabled, and verified the graph
changes were all just to add new parents that were ancestors of existing
parents.
Matt Mackall - July 1, 2015, 7:44 p.m.
On Mon, 2015-06-29 at 18:44 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1435610664 25200
> #      Mon Jun 29 13:44:24 2015 -0700
> # Node ID 76aa50d41f2919692a3586ba1f45e631d9453918
> # Parent  c4c8a8f7781e3eb4d836c13e380155e8c5ebbebe
> convert: add config option for disabling ancestor parent checks

Also wants docs. For this one, I'll allow that we might want to consider
it experimental. My soon-to-be-posted config option checker wants to see
a comment of this form:

 # experimental config: convert.ignoreancestorcheck

..which should go right about the usage.

Patch

diff --git a/hgext/convert/filemap.py b/hgext/convert/filemap.py
--- a/hgext/convert/filemap.py
+++ b/hgext/convert/filemap.py
@@ -156,6 +156,8 @@  class filemap_source(converter_source):
         self.origparents = {}
         self.children = {}
         self.seenchildren = {}
+        self.ignoreancestorcheck = self.ui.configbool('convert',
+                                                      'ignoreancestorcheck')
 
     def before(self):
         self.base.before()
@@ -306,7 +308,7 @@  class filemap_source(converter_source):
 
     def getchanges(self, rev, full):
         parents = self.commits[rev].parents
-        if len(parents) > 1:
+        if len(parents) > 1 and not self.ignoreancestorcheck:
             self.rebuild()
 
         # To decide whether we're interested in rev we:
@@ -332,9 +334,11 @@  class filemap_source(converter_source):
             mp1 = self.parentmap[p1]
             if mp1 == SKIPREV or mp1 in knownparents:
                 continue
-            isancestor = any(p2 for p2 in parents
-                                  if p1 != p2 and mp1 != self.parentmap[p2]
-                                  and mp1 in self.wantedancestors[p2])
+
+            isancestor = (not self.ignoreancestorcheck and
+                          any(p2 for p2 in parents
+                              if p1 != p2 and mp1 != self.parentmap[p2]
+                                 and mp1 in self.wantedancestors[p2]))
             if not isancestor and not hasbranchparent and len(parents) > 1:
                 # This could be expensive, avoid unnecessary calls.
                 if self._cachedcommit(p1).branch == branch: