Mercurial > hg
changeset 29236:1b7d907ec18a
changegroup: extract method that sorts nodes to send
The current implementation of narrowhg needs to influence the order in
which nodes are sent to the client. adgar@ and I think this is
fixable, but it's going to require pretty substantial time investment,
so in the interim we'd like to extract this method.
I think it makes the group() code a little more obvious, as it took us
a couple of tries to isolate the exact behavior we were observing.
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 12 May 2016 22:29:05 -0400 |
parents | 1f5052d35b30 |
children | ee935a6e1ea2 |
files | mercurial/changegroup.py |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changegroup.py Wed May 11 23:24:41 2016 +0000 +++ b/mercurial/changegroup.py Thu May 12 22:29:05 2016 -0400 @@ -530,6 +530,17 @@ def fileheader(self, fname): return chunkheader(len(fname)) + fname + # 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.""" + # 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: + dag = dagutil.revlogdag(revlog) + return dag.linearize(set(revlog.rev(n) for n in nodelist)) + else: + return sorted([revlog.rev(n) for n in nodelist]) + def group(self, nodelist, revlog, lookup, units=None): """Calculate a delta group, yielding a sequence of changegroup chunks (strings). @@ -549,14 +560,7 @@ yield self.close() return - # 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: - dag = dagutil.revlogdag(revlog) - revs = set(revlog.rev(n) for n in nodelist) - revs = dag.linearize(revs) - else: - revs = sorted([revlog.rev(n) for n in nodelist]) + revs = self._sortgroup(revlog, nodelist, lookup) # add the parent of the first rev p = revlog.parentrevs(revs[0])[0]