# HG changeset patch
# User Alexis S. L. Carvalho <alexis@cecm.usp.br>
# Date 2008-01-19 20:01:16
# Node ID 0136d7f58982cfd3b595c8441857a8002a6dbff3
# Parent  3afbd82a6c82cb0090bcb8b7e11b928e3215b5fd

allow the creation of bundles with empty changelog/manifest chunks

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -80,9 +80,13 @@ def writebundle(cg, filename, bundletype
         # in case of sshrepo because we don't know the end of the stream
 
         # an empty chunkiter is the end of the changegroup
+        # a changegroup has at least 2 chunkiters (changelog and manifest).
+        # after that, an empty chunkiter is the end of the changegroup
         empty = False
-        while not empty:
+        count = 0
+        while not empty or count <= 2:
             empty = True
+            count += 1
             for chunk in chunkiter(cg):
                 empty = False
                 fh.write(z.compress(chunkheader(len(chunk))))