comparison mercurial/changegroup.py @ 38888:c9315bc578bc

changegroup: move _sortgroup() from narrow Differential Revision: https://phab.mercurial-scm.org/D4065
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 02 Aug 2018 12:12:12 -0700
parents 75d6139e69f9
children a06aab274aef
comparison
equal deleted inserted replaced
38887:75d6139e69f9 38888:c9315bc578bc
557 return chunkheader(len(fname)) + fname 557 return chunkheader(len(fname)) + fname
558 558
559 # Extracted both for clarity and for overriding in extensions. 559 # Extracted both for clarity and for overriding in extensions.
560 def _sortgroup(self, revlog, nodelist, lookup): 560 def _sortgroup(self, revlog, nodelist, lookup):
561 """Sort nodes for change group and turn them into revnums.""" 561 """Sort nodes for change group and turn them into revnums."""
562 # Ellipses serving mode.
563 #
564 # In a perfect world, we'd generate better ellipsis-ified graphs
565 # for non-changelog revlogs. In practice, we haven't started doing
566 # that yet, so the resulting DAGs for the manifestlog and filelogs
567 # are actually full of bogus parentage on all the ellipsis
568 # nodes. This has the side effect that, while the contents are
569 # correct, the individual DAGs might be completely out of whack in
570 # a case like 882681bc3166 and its ancestors (back about 10
571 # revisions or so) in the main hg repo.
572 #
573 # The one invariant we *know* holds is that the new (potentially
574 # bogus) DAG shape will be valid if we order the nodes in the
575 # order that they're introduced in dramatis personae by the
576 # changelog, so what we do is we sort the non-changelog histories
577 # by the order in which they are used by the changelog.
578 if util.safehasattr(self, 'full_nodes') and self.clnode_to_rev:
579 key = lambda n: self.clnode_to_rev[lookup(n)]
580 return [revlog.rev(n) for n in sorted(nodelist, key=key)]
581
562 # for generaldelta revlogs, we linearize the revs; this will both be 582 # for generaldelta revlogs, we linearize the revs; this will both be
563 # much quicker and generate a much smaller bundle 583 # much quicker and generate a much smaller bundle
564 if (revlog._generaldelta and self._reorder is None) or self._reorder: 584 if (revlog._generaldelta and self._reorder is None) or self._reorder:
565 dag = dagutil.revlogdag(revlog) 585 dag = dagutil.revlogdag(revlog)
566 return dag.linearize(set(revlog.rev(n) for n in nodelist)) 586 return dag.linearize(set(revlog.rev(n) for n in nodelist))