[PATCH 1 of 1] get rid of unbundler in changegroup(subset)/getbundle

Sune Foldager cryo at cyanite.org
Sun Jun 5 09:29:55 CDT 2011


# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1307283524 -7200
# Node ID d577a4faec1b4dc007327a706a01db30a688a652
# Parent  b88368a3ade4b748c8e01cf0453158f80e558a7a
get rid of unbundler in changegroup(subset)/getbundle

The unbundler (the unbundle10 class), currently serves two purposes:
1. holding an underlying stream which is read from start to finish.
2. helping with the actual unbundling process.

1 is used on the server for sending a bundle back to the client, and for
writing bundles locally to disk. 2 is used on the client to apply a bundle to
the repository. This patch removes the unbundler from the "1" code since it's
redundant there (because the bundle data isn't applied).

It also adds a helper method to obtain the unbundler, since the new bundle
format code will introduce another unbundle class.

diff -r b88368a3ade4 -r d577a4faec1b mercurial/changegroup.py
--- a/mercurial/changegroup.py	Sun Jun 05 13:27:06 2011 +0200
+++ b/mercurial/changegroup.py	Sun Jun 05 16:18:44 2011 +0200
@@ -194,6 +194,9 @@
         return dict(node=node, p1=p1, p2=p2, cs=cs,
                     deltabase=deltabase, delta=delta)
 
+def unbundler(source):
+    return unbundle10(source, 'UN')
+
 class headerlessfixup(object):
     def __init__(self, fh, h):
         self._h = h
diff -r b88368a3ade4 -r d577a4faec1b mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sun Jun 05 13:27:06 2011 +0200
+++ b/mercurial/localrepo.py	Sun Jun 05 16:18:44 2011 +0200
@@ -1582,7 +1582,7 @@
             if csets:
                 self.hook('outgoing', node=hex(csets[0]), source=source)
 
-        return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
+        return util.chunkbuffer(gengroup())
 
     def changegroup(self, basenodes, source):
         # to avoid a race we use changegroupsubset() (issue1320)
@@ -1671,7 +1671,7 @@
             if nodes:
                 self.hook('outgoing', node=hex(nodes[0]), source=source)
 
-        return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
+        return util.chunkbuffer(gengroup())
 
     def addchangegroup(self, source, srctype, url, emptyok=False, lock=None):
         """Add the changegroup returned by source.read() to this repo.
@@ -1698,6 +1698,7 @@
 
         self.hook('prechangegroup', throw=True, source=srctype, url=url)
 
+        source = changegroup.unbundler(source)
         changesets = files = revisions = 0
         efiles = set()
 
diff -r b88368a3ade4 -r d577a4faec1b mercurial/sshserver.py
--- a/mercurial/sshserver.py	Sun Jun 05 13:27:06 2011 +0200
+++ b/mercurial/sshserver.py	Sun Jun 05 16:18:44 2011 +0200
@@ -6,7 +6,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import util, hook, wireproto, changegroup
+import util, hook, wireproto
 import os, sys
 
 class sshserver(object):
@@ -134,8 +134,7 @@
             return
 
         self.sendresponse("")
-        cg = changegroup.unbundle10(self.fin, "UN")
-        r = self.repo.addchangegroup(cg, 'serve', self._client(),
+        r = self.repo.addchangegroup(self.fin, 'serve', self._client(),
                                      lock=self.lock)
         return str(r)
 
diff -r b88368a3ade4 -r d577a4faec1b mercurial/wireproto.py
--- a/mercurial/wireproto.py	Sun Jun 05 13:27:06 2011 +0200
+++ b/mercurial/wireproto.py	Sun Jun 05 16:18:44 2011 +0200
@@ -113,7 +113,7 @@
     def changegroup(self, nodes, kind):
         n = encodelist(nodes)
         f = self._callstream("changegroup", roots=n)
-        return changegroupmod.unbundle10(self._decompress(f), 'UN')
+        return self._decompress(f)
 
     def changegroupsubset(self, bases, heads, kind):
         self.requirecap('changegroupsubset', _('look up remote changes'))
@@ -121,7 +121,7 @@
         heads = encodelist(heads)
         f = self._callstream("changegroupsubset",
                              bases=bases, heads=heads)
-        return changegroupmod.unbundle10(self._decompress(f), 'UN')
+        return self._decompress(f)
 
     def getbundle(self, source, heads=None, common=None):
         self.requirecap('getbundle', _('look up remote changes'))
@@ -131,7 +131,7 @@
         if common is not None:
             opts['common'] = encodelist(common)
         f = self._callstream("getbundle", **opts)
-        return changegroupmod.unbundle10(self._decompress(f), 'UN')
+        return self._decompress(f)
 
     def unbundle(self, cg, heads, source):
         '''Send cg (a readable file-like object representing the


More information about the Mercurial-devel mailing list