[PATCH 1 of 3 main-line-of-works (35 more patches to go)] bundle2: introduce a specific function for bundling debug message

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu May 28 04:37:26 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1432705743 25200
#      Tue May 26 22:49:03 2015 -0700
# Node ID 03ca83e664e181f3c83a6c40779100822291675d
# Parent  bcb17d7dbec25088eaec5e4d34dedbd7057c5d68
bundle2: introduce a specific function for bundling debug message

The bundling process is very verbose, we would like to be able to hide such
output behind a configuration flag and have it more explicitly referencing
bundle2. The first step is to gather all these messages in a dedicated
function.

The same gathering will be later do for debug message issue by unbundling.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -171,10 +171,14 @@ from i18n import _
 
 preferedchunksize = 4096
 
 _parttypeforbidden = re.compile('[^a-zA-Z0-9_:-]')
 
+def outdebug(ui, message):
+    """debug regarding output stream (bundling)"""
+    ui.debug(message)
+
 def validateparttype(parttype):
     """raise ValueError if a parttype contains invalid character"""
     if _parttypeforbidden.search(parttype):
         raise ValueError(parttype)
 
@@ -462,24 +466,24 @@ class bundle20(object):
         self.addpart(part)
         return part
 
     # methods used to generate the bundle2 stream
     def getchunks(self):
-        self.ui.debug('start emission of %s stream\n' % self._magicstring)
+        outdebug(self.ui, 'start emission of %s stream\n' % self._magicstring)
         yield self._magicstring
         param = self._paramchunk()
-        self.ui.debug('bundle parameter: %s\n' % param)
+        outdebug(self.ui, 'bundle parameter: %s\n' % param)
         yield _pack(_fstreamparamsize, len(param))
         if param:
             yield param
 
-        self.ui.debug('start of parts\n')
+        outdebug(self.ui, 'start of parts\n')
         for part in self._parts:
-            self.ui.debug('bundle part: "%s"\n' % part.type)
+            outdebug(self.ui, 'bundle part: "%s"\n' % part.type)
             for chunk in part.getchunks():
                 yield chunk
-        self.ui.debug('end of bundle\n')
+        outdebug(self.ui, 'end of bundle\n')
         yield _pack(_fpartheadersize, 0)
 
     def _paramchunk(self):
         """return a encoded version of all stream parameters"""
         blocks = []


More information about the Mercurial-devel mailing list