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
--- 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)
--- 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