# HG changeset patch # User Gregory Szorc # Date 1533228018 25200 # Node ID 5839a170357db0740851abe107a03d6dc8fb3cfd # Parent a2f521773761c74dc8b0adaef9f3960d393ef426 changegroup: move deltaparent() from narrow I'm not keen on performing the attribute sniff to test for presence of ellipses mode: I'd rather we use a separate packer instance that was ellipses mode specific. But I've tried to formalize a better API without narrow in core and I can't make sense of all the monkeypatching. My goal is to inline as much of the monkeypatching as possible then refactor the changegroup generation API. We add this code to the cg2packer because narrow doesn't work with cg1. Differential Revision: https://phab.mercurial-scm.org/D4062 diff -r a2f521773761 -r 5839a170357d hgext/narrow/narrowchangegroup.py --- a/hgext/narrow/narrowchangegroup.py Sat Jul 28 17:59:37 2018 -0700 +++ b/hgext/narrow/narrowchangegroup.py Thu Aug 02 09:40:18 2018 -0700 @@ -316,20 +316,3 @@ yield changegroup.ellipsisdata( self, rev, revlog, p1, p2, revlog.revision(n), linknode) extensions.wrapfunction(changegroup.cg1packer, 'revchunk', revchunk) - - def deltaparent(orig, self, revlog, rev, p1, p2, prev): - if util.safehasattr(self, 'full_nodes'): - # TODO: send better deltas when in narrow mode. - # - # changegroup.group() loops over revisions to send, - # including revisions we'll skip. What this means is that - # `prev` will be a potentially useless delta base for all - # ellipsis nodes, as the client likely won't have it. In - # the future we should do bookkeeping about which nodes - # have been sent to the client, and try to be - # significantly smarter about delta bases. This is - # slightly tricky because this same code has to work for - # all revlogs, and we don't have the linkrev/linknode here. - return p1 - return orig(self, revlog, rev, p1, p2, prev) - extensions.wrapfunction(changegroup.cg2packer, 'deltaparent', deltaparent) diff -r a2f521773761 -r 5839a170357d mercurial/changegroup.py --- a/mercurial/changegroup.py Sat Jul 28 17:59:37 2018 -0700 +++ b/mercurial/changegroup.py Thu Aug 02 09:40:18 2018 -0700 @@ -851,6 +851,21 @@ self._reorder = False def deltaparent(self, revlog, rev, p1, p2, prev): + # Narrow ellipses mode. + if util.safehasattr(self, 'full_nodes'): + # TODO: send better deltas when in narrow mode. + # + # changegroup.group() loops over revisions to send, + # including revisions we'll skip. What this means is that + # `prev` will be a potentially useless delta base for all + # ellipsis nodes, as the client likely won't have it. In + # the future we should do bookkeeping about which nodes + # have been sent to the client, and try to be + # significantly smarter about delta bases. This is + # slightly tricky because this same code has to work for + # all revlogs, and we don't have the linkrev/linknode here. + return p1 + dp = revlog.deltaparent(rev) if dp == nullrev and revlog.storedeltachains: # Avoid sending full revisions when delta parent is null. Pick prev