Patchwork D4060: changegroup: move ellipsisdata() from narrow

login
register
mail settings
Submitter phabricator
Date Aug. 6, 2018, 6:56 a.m.
Message ID <3fad099475563ccbcd69037f1608bd1d@localhost.localdomain>
Download mbox | patch
Permalink /patch/33287/
State Not Applicable
Headers show

Comments

phabricator - Aug. 6, 2018, 6:56 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGee1ea96cf9c9: changegroup: move ellipsisdata() from narrow (authored by indygreg, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D4060?vs=9800&id=9941#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4060?vs=9800&id=9941

REVISION DETAIL
  https://phab.mercurial-scm.org/D4060

AFFECTED FILES
  hgext/narrow/narrowchangegroup.py
  mercurial/changegroup.py

CHANGE DETAILS




To: indygreg, durin42, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -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'
diff --git a/hgext/narrow/narrowchangegroup.py b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -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)