changegroup: move ellipsisdata() from narrow
This is a pretty straightforward copy of the function.
Differential Revision: https://phab.mercurial-scm.org/D4060
--- a/hgext/narrow/narrowchangegroup.py Sun Jul 22 19:48:50 2018 +0900
+++ b/hgext/narrow/narrowchangegroup.py Sat Jul 28 17:52:21 2018 -0700
@@ -12,10 +12,8 @@
changegroup,
error,
extensions,
- mdiff,
node,
pycompat,
- revlog,
util,
)
@@ -54,21 +52,6 @@
extensions.wrapfunction(
changegroup.cg1packer, 'generatefiles', generatefiles)
- def ellipsisdata(packer, rev, revlog_, p1, p2, data, linknode):
- n = revlog_.node(rev)
- p1n, p2n = revlog_.node(p1), revlog_.node(p2)
- flags = revlog_.flags(rev)
- flags |= revlog.REVIDX_ELLIPSIS
- meta = packer.builddeltaheader(
- n, p1n, p2n, node.nullid, linknode, flags)
- # TODO: try and actually send deltas for ellipsis data blocks
- diffheader = mdiff.trivialdiffheader(len(data))
- l = len(meta) + len(diffheader) + len(data)
- return ''.join((changegroup.chunkheader(l),
- meta,
- diffheader,
- data))
-
def close(orig, self):
getattr(self, 'clrev_to_localrev', {}).clear()
if getattr(self, 'next_clrev_to_localrev', {}):
@@ -330,7 +313,7 @@
else:
p1, p2 = sorted(local(p) for p in linkparents)
n = revlog.node(rev)
- yield ellipsisdata(
+ yield changegroup.ellipsisdata(
self, rev, revlog, p1, p2, revlog.revision(n), linknode)
extensions.wrapfunction(changegroup.cg1packer, 'revchunk', revchunk)
--- a/mercurial/changegroup.py Sun Jul 22 19:48:50 2018 +0900
+++ b/mercurial/changegroup.py Sat Jul 28 17:52:21 2018 -0700
@@ -14,6 +14,7 @@
from .i18n import _
from .node import (
hex,
+ nullid,
nullrev,
short,
)
@@ -27,6 +28,7 @@
phases,
pycompat,
repository,
+ revlog,
util,
)
@@ -492,6 +494,21 @@
return d
return readexactly(self._fh, n)
+def ellipsisdata(packer, rev, revlog_, p1, p2, data, linknode):
+ n = revlog_.node(rev)
+ p1n, p2n = revlog_.node(p1), revlog_.node(p2)
+ flags = revlog_.flags(rev)
+ flags |= revlog.REVIDX_ELLIPSIS
+ meta = packer.builddeltaheader(
+ n, p1n, p2n, nullid, linknode, flags)
+ # TODO: try and actually send deltas for ellipsis data blocks
+ diffheader = mdiff.trivialdiffheader(len(data))
+ l = len(meta) + len(diffheader) + len(data)
+ return ''.join((chunkheader(l),
+ meta,
+ diffheader,
+ data))
+
class cg1packer(object):
deltaheader = _CHANGEGROUPV1_DELTA_HEADER
version = '01'