Patchwork D4082: changegroup: control reordering via constructor argument

login
register
mail settings
Submitter phabricator
Date Aug. 6, 2018, 6:57 a.m.
Message ID <dff2b301bcfcb6ad132872b77083060e@localhost.localdomain>
Download mbox | patch
Permalink /patch/33303/
State Not Applicable
Headers show

Comments

phabricator - Aug. 6, 2018, 6:57 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6e999a2d8fe7: changegroup: control reordering via constructor argument (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4082?vs=9844&id=9959

REVISION DETAIL
  https://phab.mercurial-scm.org/D4082

AFFECTED FILES
  mercurial/changegroup.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -520,14 +520,18 @@ 
     deltachunks = attr.ib()
 
 class cg1packer(object):
-    def __init__(self, repo, filematcher, version, builddeltaheader,
-                 manifestsend, sendtreemanifests,
+    def __init__(self, repo, filematcher, version, allowreorder,
+                 builddeltaheader, manifestsend, sendtreemanifests,
                  bundlecaps=None):
         """Given a source repo, construct a bundler.
 
         filematcher is a matcher that matches on files to include in the
         changegroup. Used to facilitate sparse changegroups.
 
+        allowreorder controls whether reordering of revisions is allowed.
+        This value is used when ``bundle.reorder`` is ``auto`` or isn't
+        set.
+
         builddeltaheader is a callable that constructs the header for a group
         delta.
 
@@ -552,14 +556,16 @@ 
         if bundlecaps is None:
             bundlecaps = set()
         self._bundlecaps = bundlecaps
+
         # experimental config: bundle.reorder
         reorder = repo.ui.config('bundle', 'reorder')
         if reorder == 'auto':
-            reorder = None
+            self._reorder = allowreorder
         else:
-            reorder = stringutil.parsebool(reorder)
+            self._reorder = stringutil.parsebool(reorder)
+
         self._repo = repo
-        self._reorder = reorder
+
         if self._repo.ui.verbose and not self._repo.ui.debugflag:
             self._verbosenote = self._repo.ui.note
         else:
@@ -1120,19 +1126,6 @@ 
         )
 
 class cg2packer(cg1packer):
-    def __init__(self, repo, filematcher, version, builddeltaheader,
-                 manifestsend, sendtreemanifests, bundlecaps=None):
-        super(cg2packer, self).__init__(repo, filematcher, version,
-                                        builddeltaheader, manifestsend,
-                                        sendtreemanifests,
-                                        bundlecaps=bundlecaps)
-
-        if self._reorder is None:
-            # Since generaldelta is directly supported by cg2, reordering
-            # generally doesn't help, so we disable it by default (treating
-            # bundle.reorder=auto just like bundle.reorder=False).
-            self._reorder = False
-
     def deltaparent(self, store, rev, p1, p2, prev):
         # Narrow ellipses mode.
         if util.safehasattr(self, 'full_nodes'):
@@ -1176,23 +1169,29 @@ 
     builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack(
         d.node, d.p1node, d.p2node, d.linknode)
 
-    return cg1packer(repo, filematcher, b'01', builddeltaheader,
+    return cg1packer(repo, filematcher, b'01', allowreorder=None,
+                     builddeltaheader=builddeltaheader,
                      manifestsend=b'', sendtreemanifests=False,
                      bundlecaps=bundlecaps)
 
 def _makecg2packer(repo, filematcher, bundlecaps):
     builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack(
         d.node, d.p1node, d.p2node, d.basenode, d.linknode)
 
-    return cg2packer(repo, filematcher, b'02', builddeltaheader,
+    # Since generaldelta is directly supported by cg2, reordering
+    # generally doesn't help, so we disable it by default (treating
+    # bundle.reorder=auto just like bundle.reorder=False).
+    return cg2packer(repo, filematcher, b'02', allowreorder=False,
+                     builddeltaheader=builddeltaheader,
                      manifestsend=b'', sendtreemanifests=False,
                      bundlecaps=bundlecaps)
 
 def _makecg3packer(repo, filematcher, bundlecaps):
     builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack(
         d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags)
 
-    return cg2packer(repo, filematcher, b'03', builddeltaheader,
+    return cg2packer(repo, filematcher, b'03', allowreorder=False,
+                     builddeltaheader=builddeltaheader,
                      manifestsend=closechunk(), sendtreemanifests=True,
                      bundlecaps=bundlecaps)