diff mercurial/revlog.py @ 1981:736b6c96bbbc

make incoming work via ssh (issue139); move chunk code into separate module. Incoming ssh needs to detect the end of the changegroup, otherwise it would block trying to read from the ssh pipe. This is done by parsing the changegroup chunks. bundlerepo.getchunk() already is identical to localrepo.addchangegroup.getchunk(), which is followed by getgroup which looks much like what you can re-use in bundlerepository.__init__() and in write_bundle(). bundlerevlog.__init__.genchunk() looks very similar, too, as do some while loops in localrepo.py. Applied patch from Benoit Boissinot to move duplicate/related code to mercurial/changegroup.py and use this to fix incoming ssh.
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 21 Mar 2006 11:47:21 +0100
parents 7518823709a2
children 4aab906517c6
line wrap: on
line diff
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -13,7 +13,8 @@ of the GNU General Public License, incor
 from node import *
 from i18n import gettext as _
 from demandload import demandload
-demandload(globals(), "binascii errno heapq mdiff os sha struct zlib")
+demandload(globals(), "binascii changegroup errno heapq mdiff os")
+demandload(globals(), "sha struct zlib")
 
 def hash(text, p1, p2):
     """generate a hash from the given text and its parent hashes
@@ -708,7 +709,7 @@ class revlog(object):
 
         # if we don't have any revisions touched by these changesets, bail
         if not revs:
-            yield struct.pack(">l", 0)
+            yield changegroup.closechunk()
             return
 
         # add the parent of the first rev
@@ -726,12 +727,9 @@ class revlog(object):
             d = self.revdiff(a, b)
             p = self.parents(nb)
             meta = nb + p[0] + p[1] + lookup(nb)
-            l = struct.pack(">l", len(meta) + len(d) + 4)
-            yield l
-            yield meta
-            yield d
+            yield changegroup.genchunk("%s%s" % (meta, d))
 
-        yield struct.pack(">l", 0)
+        yield changegroup.closechunk()
 
     def addgroup(self, revs, linkmapper, transaction, unique=0):
         """