changeset 25313:8f2c362bcb58

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 26 May 2015 22:49:03 -0700
parents ee02728dd5f9
children 18c2bcc2c9d5
files mercurial/bundle2.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed May 27 17:01:43 2015 -0700
+++ b/mercurial/bundle2.py	Tue May 26 22:49:03 2015 -0700
@@ -173,6 +173,10 @@
 
 _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):
@@ -464,20 +468,20 @@
 
     # 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):