The code should functionally be identical.
We also port the one consumer in changegroup to use the new
standalone function.
After this commit, dagutil is no longer used!
hg-reviewers |
The code should functionally be identical.
We also port the one consumer in changegroup to use the new
standalone function.
After this commit, dagutil is no longer used!
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/changegroup.py (6 lines) | |||
M | mercurial/dagop.py (37 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | D4330 dagutil: remove module | |
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 |
short, | short, | ||||
) | ) | ||||
from .thirdparty import ( | from .thirdparty import ( | ||||
attr, | attr, | ||||
) | ) | ||||
from . import ( | from . import ( | ||||
dagutil, | dagop, | ||||
error, | error, | ||||
match as matchmod, | match as matchmod, | ||||
mdiff, | mdiff, | ||||
phases, | phases, | ||||
pycompat, | pycompat, | ||||
repository, | repository, | ||||
revlog, | revlog, | ||||
util, | util, | ||||
yield prefix | yield prefix | ||||
yield data | yield data | ||||
def _sortnodesnormal(store, nodes, reorder): | def _sortnodesnormal(store, nodes, reorder): | ||||
"""Sort nodes for changegroup generation and turn into revnums.""" | """Sort nodes for changegroup generation and turn into revnums.""" | ||||
# 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 (store._generaldelta and reorder is None) or reorder: | if (store._generaldelta and reorder is None) or reorder: | ||||
dag = dagutil.revlogdag(store) | revs = set(store.rev(n) for n in nodes) | ||||
return dag.linearize(set(store.rev(n) for n in nodes)) | return dagop.linearize(revs, store.parentrevs) | ||||
else: | else: | ||||
return sorted([store.rev(n) for n in nodes]) | return sorted([store.rev(n) for n in nodes]) | ||||
def _sortnodesellipsis(store, nodes, cl, lookup): | def _sortnodesellipsis(store, nodes, cl, lookup): | ||||
"""Sort nodes for changegroup generation and turn into revnums.""" | """Sort nodes for changegroup generation and turn into revnums.""" | ||||
# Ellipses serving mode. | # Ellipses serving mode. | ||||
# | # | ||||
# In a perfect world, we'd generate better ellipsis-ified graphs | # In a perfect world, we'd generate better ellipsis-ified graphs |
for rev in revs: | for rev in revs: | ||||
for prev in parentsfn(rev): | for prev in parentsfn(rev): | ||||
headrevs.discard(prev) | headrevs.discard(prev) | ||||
headrevs.discard(node.nullrev) | headrevs.discard(node.nullrev) | ||||
return headrevs | return headrevs | ||||
def linearize(revs, parentsfn): | |||||
"""Linearize and topologically sort a list of revisions. | |||||
The linearization process tires to create long runs of revs where a child | |||||
rev comes immediately after its first parent. This is done by visiting the | |||||
heads of the revs in inverse topological order, and for each visited rev, | |||||
visiting its second parent, then its first parent, then adding the rev | |||||
itself to the output list. | |||||
Returns a list of revision numbers. | |||||
""" | |||||
visit = list(sorted(headrevs(revs, parentsfn), reverse=True)) | |||||
finished = set() | |||||
result = [] | |||||
while visit: | |||||
rev = visit.pop() | |||||
if rev < 0: | |||||
rev = -rev - 1 | |||||
if rev not in finished: | |||||
result.append(rev) | |||||
finished.add(rev) | |||||
else: | |||||
visit.append(-rev - 1) | |||||
for prev in parentsfn(rev): | |||||
if prev == node.nullrev or prev not in revs or prev in finished: | |||||
continue | |||||
visit.append(prev) | |||||
assert len(result) == len(revs) | |||||
return result |