diff mercurial/changegroup.py @ 13831:d69c9510d648

changegroup: introduce bundler objects This makes the bundler pluggable at lower levels.
author Matt Mackall <mpm@selenic.com>
date Thu, 31 Mar 2011 15:24:06 -0500
parents 4ed718f909e5
children aaa9a5989405
line wrap: on
line diff
--- a/mercurial/changegroup.py	Thu Mar 31 14:25:26 2011 -0500
+++ b/mercurial/changegroup.py	Thu Mar 31 15:24:06 2011 -0500
@@ -194,3 +194,18 @@
     if version != '10':
         raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
     return unbundle10(fh, alg)
+
+class bundle10(object):
+    def __init__(self, lookup):
+        self._lookup = lookup
+    def close(self):
+        return closechunk()
+    def fileheader(self, fname):
+        return chunkheader(len(fname)) + fname
+    def revchunk(self, revlog, node='', p1='', p2='', prefix='', data=''):
+        linknode = self._lookup(revlog, node)
+        meta = node + p1 + p2 + linknode + prefix
+        l = len(meta) + len(data)
+        yield chunkheader(l)
+        yield meta
+        yield data