Patchwork D4065: changegroup: move _sortgroup() from narrow

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

Comments

phabricator - Aug. 6, 2018, 6:56 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc9315bc578bc: changegroup: move _sortgroup() from narrow (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4065?vs=9805&id=9945

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

AFFECTED FILES
  hgext/narrow/narrowchangegroup.py
  mercurial/changegroup.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -559,6 +559,26 @@ 
     # Extracted both for clarity and for overriding in extensions.
     def _sortgroup(self, revlog, nodelist, lookup):
         """Sort nodes for change group and turn them into revnums."""
+        # Ellipses serving mode.
+        #
+        # In a perfect world, we'd generate better ellipsis-ified graphs
+        # for non-changelog revlogs. In practice, we haven't started doing
+        # that yet, so the resulting DAGs for the manifestlog and filelogs
+        # are actually full of bogus parentage on all the ellipsis
+        # nodes. This has the side effect that, while the contents are
+        # correct, the individual DAGs might be completely out of whack in
+        # a case like 882681bc3166 and its ancestors (back about 10
+        # revisions or so) in the main hg repo.
+        #
+        # The one invariant we *know* holds is that the new (potentially
+        # bogus) DAG shape will be valid if we order the nodes in the
+        # order that they're introduced in dramatis personae by the
+        # changelog, so what we do is we sort the non-changelog histories
+        # by the order in which they are used by the changelog.
+        if util.safehasattr(self, 'full_nodes') and self.clnode_to_rev:
+            key = lambda n: self.clnode_to_rev[lookup(n)]
+            return [revlog.rev(n) for n in sorted(nodelist, key=key)]
+
         # for generaldelta revlogs, we linearize the revs; this will both be
         # much quicker and generate a much smaller bundle
         if (revlog._generaldelta and self._reorder is None) or self._reorder:
diff --git a/hgext/narrow/narrowchangegroup.py b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -51,28 +51,6 @@ 
     extensions.wrapfunction(
         changegroup.cg1packer, 'generatefiles', generatefiles)
 
-    # In a perfect world, we'd generate better ellipsis-ified graphs
-    # for non-changelog revlogs. In practice, we haven't started doing
-    # that yet, so the resulting DAGs for the manifestlog and filelogs
-    # are actually full of bogus parentage on all the ellipsis
-    # nodes. This has the side effect that, while the contents are
-    # correct, the individual DAGs might be completely out of whack in
-    # a case like 882681bc3166 and its ancestors (back about 10
-    # revisions or so) in the main hg repo.
-    #
-    # The one invariant we *know* holds is that the new (potentially
-    # bogus) DAG shape will be valid if we order the nodes in the
-    # order that they're introduced in dramatis personae by the
-    # changelog, so what we do is we sort the non-changelog histories
-    # by the order in which they are used by the changelog.
-    def _sortgroup(orig, self, revlog, nodelist, lookup):
-        if not util.safehasattr(self, 'full_nodes') or not self.clnode_to_rev:
-            return orig(self, revlog, nodelist, lookup)
-        key = lambda n: self.clnode_to_rev[lookup(n)]
-        return [revlog.rev(n) for n in sorted(nodelist, key=key)]
-
-    extensions.wrapfunction(changegroup.cg1packer, '_sortgroup', _sortgroup)
-
     def generate(orig, self, commonrevs, clnodes, fastpathlinkrev, source):
         '''yield a sequence of changegroup chunks (strings)'''
         # Note: other than delegating to orig, the only deviation in