Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHGc9315bc578bc: changegroup: move _sortgroup() from narrow
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
durin42 |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/narrow/narrowchangegroup.py (22 lines) | |||
M | mercurial/changegroup.py (20 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Aug 2 2018, 3:12 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg |
links[fnode] = min(links[fnode], lr, key=clrev) | links[fnode] = min(links[fnode], lr, key=clrev) | ||||
elif fnode: | elif fnode: | ||||
links[fnode] = lr | links[fnode] = lr | ||||
return links | return links | ||||
return orig(self, changedfiles, linknodes, commonrevs, source) | return orig(self, changedfiles, linknodes, commonrevs, source) | ||||
extensions.wrapfunction( | extensions.wrapfunction( | ||||
changegroup.cg1packer, 'generatefiles', generatefiles) | 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): | def generate(orig, self, commonrevs, clnodes, fastpathlinkrev, source): | ||||
'''yield a sequence of changegroup chunks (strings)''' | '''yield a sequence of changegroup chunks (strings)''' | ||||
# Note: other than delegating to orig, the only deviation in | # Note: other than delegating to orig, the only deviation in | ||||
# logic from normal hg's generate is marked with BEGIN/END | # logic from normal hg's generate is marked with BEGIN/END | ||||
# NARROW HACK. | # NARROW HACK. | ||||
if not util.safehasattr(self, 'full_nodes'): | if not util.safehasattr(self, 'full_nodes'): | ||||
# not sending a narrow bundle | # not sending a narrow bundle | ||||
for x in orig(self, commonrevs, clnodes, fastpathlinkrev, source): | for x in orig(self, commonrevs, clnodes, fastpathlinkrev, source): |
return closechunk() | return closechunk() | ||||
def fileheader(self, fname): | def fileheader(self, fname): | ||||
return chunkheader(len(fname)) + fname | return chunkheader(len(fname)) + fname | ||||
# Extracted both for clarity and for overriding in extensions. | # Extracted both for clarity and for overriding in extensions. | ||||
def _sortgroup(self, revlog, nodelist, lookup): | def _sortgroup(self, revlog, nodelist, lookup): | ||||
"""Sort nodes for change group and turn them into revnums.""" | """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 | # for generaldelta revlogs, we linearize the revs; this will both be | ||||
# much quicker and generate a much smaller bundle | # much quicker and generate a much smaller bundle | ||||
if (revlog._generaldelta and self._reorder is None) or self._reorder: | if (revlog._generaldelta and self._reorder is None) or self._reorder: | ||||
dag = dagutil.revlogdag(revlog) | dag = dagutil.revlogdag(revlog) | ||||
return dag.linearize(set(revlog.rev(n) for n in nodelist)) | return dag.linearize(set(revlog.rev(n) for n in nodelist)) | ||||
else: | else: | ||||
return sorted([revlog.rev(n) for n in nodelist]) | return sorted([revlog.rev(n) for n in nodelist]) | ||||