Patchwork [4,of,8] bundle2: handle new line in 'indebug' function

login
register
mail settings
Submitter Pierre-Yves David
Date May 29, 2015, 9:21 p.m.
Message ID <697d8953b04d88c5da40.1432934517@waste.org>
Download mbox | patch
Permalink /patch/9391/
State Accepted
Headers show

Comments

Pierre-Yves David - May 29, 2015, 9:21 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1432706499 25200
#      Tue May 26 23:01:39 2015 -0700
# Node ID 697d8953b04d88c5da40ccb94db289b3eeb403db
# Parent  c3ef4f3b868043e4131692a48bb76dafbad9761d
bundle2: handle new line in 'indebug' function

Now that we have a prefix, it make sense to assume all output will be on a
single line.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -179,7 +179,7 @@ 
 
 def indebug(ui, message):
     """debug on input stream (unbundling)"""
-    ui.debug('bundle2-input: %s' % message)
+    ui.debug('bundle2-input: %s\n' % message)
 
 def validateparttype(parttype):
     """raise ValueError if a parttype contains invalid character"""
@@ -350,7 +350,7 @@ 
             handler = parthandlermapping.get(part.type)
             if handler is None:
                 raise error.UnsupportedPartError(parttype=part.type)
-            indebug(op.ui, 'found a handler for part %r\n' % part.type)
+            indebug(op.ui, 'found a handler for part %r' % part.type)
             unknownparams = part.mandatorykeys - handler.params
             if unknownparams:
                 unknownparams = list(unknownparams)
@@ -360,7 +360,7 @@ 
         except error.UnsupportedPartError, exc:
             if part.mandatory: # mandatory parts
                 raise
-            indebug(op.ui, 'ignoring unsupported advisory part %s\n' % exc)
+            indebug(op.ui, 'ignoring unsupported advisory part %s' % exc)
             return # skip to part processing
 
         # handler is called outside the above try block so that we don't
@@ -563,7 +563,7 @@ 
     if unbundlerclass is None:
         raise util.Abort(_('unknown bundle version %s') % version)
     unbundler = unbundlerclass(ui, fp)
-    indebug(ui, 'start processing of %s stream\n' % header)
+    indebug(ui, 'start processing of %s stream' % header)
     return unbundler
 
 class unbundle20(unpackermixin):
@@ -580,7 +580,7 @@ 
     @util.propertycache
     def params(self):
         """dictionary of stream level parameters"""
-        indebug(self.ui, 'reading bundle2 stream parameters\n')
+        indebug(self.ui, 'reading bundle2 stream parameters')
         params = {}
         paramssize = self._unpack(_fstreamparamsize)[0]
         if paramssize < 0:
@@ -613,7 +613,7 @@ 
         # Some logic will be later added here to try to process the option for
         # a dict of known parameter.
         if name[0].islower():
-            indebug(self.ui, "ignoring unknown parameter %r\n" % name)
+            indebug(self.ui, "ignoring unknown parameter %r" % name)
         else:
             raise error.UnsupportedPartError(params=(name,))
 
@@ -622,14 +622,14 @@ 
         """yield all parts contained in the stream"""
         # make sure param have been loaded
         self.params
-        indebug(self.ui, 'start extraction of bundle2 parts\n')
+        indebug(self.ui, 'start extraction of bundle2 parts')
         headerblock = self._readpartheader()
         while headerblock is not None:
             part = unbundlepart(self.ui, headerblock, self._fp)
             yield part
             part.seek(0, 2)
             headerblock = self._readpartheader()
-        indebug(self.ui, 'end of bundle2 stream\n')
+        indebug(self.ui, 'end of bundle2 stream')
 
     def _readpartheader(self):
         """reads a part header size and return the bytes blob
@@ -639,7 +639,7 @@ 
         if headersize < 0:
             raise error.BundleValueError('negative part header size: %i'
                                          % headersize)
-        indebug(self.ui, 'part header size: %i\n' % headersize)
+        indebug(self.ui, 'part header size: %i' % headersize)
         if headersize:
             return self._readexact(headersize)
         return None
@@ -831,10 +831,10 @@ 
         return None
 
     def __call__(self):
-        indebug(self.ui, 'bundle2 stream interruption, looking for a part.\n')
+        indebug(self.ui, 'bundle2 stream interruption, looking for a part.')
         headerblock = self._readpartheader()
         if headerblock is None:
-            indebug(self.ui, 'no part found during interruption.\n')
+            indebug(self.ui, 'no part found during interruption.')
             return
         part = unbundlepart(self.ui, headerblock, self._fp)
         op = interruptoperation(self.ui)
@@ -918,7 +918,7 @@ 
 
         pos = self._chunkindex[chunknum][0]
         payloadsize = self._unpack(_fpayloadsize)[0]
-        indebug(self.ui, 'payload chunk size: %i\n' % payloadsize)
+        indebug(self.ui, 'payload chunk size: %i' % payloadsize)
         while payloadsize:
             if payloadsize == flaginterrupt:
                 # interruption detection, the handler will now read a
@@ -936,7 +936,7 @@ 
                                              super(unbundlepart, self).tell()))
                 yield result
             payloadsize = self._unpack(_fpayloadsize)[0]
-            indebug(self.ui, 'payload chunk size: %i\n' % payloadsize)
+            indebug(self.ui, 'payload chunk size: %i' % payloadsize)
 
     def _findchunk(self, pos):
         '''for a given payload position, return a chunk number and offset'''
@@ -951,16 +951,16 @@ 
         """read the header and setup the object"""
         typesize = self._unpackheader(_fparttypesize)[0]
         self.type = self._fromheader(typesize)
-        indebug(self.ui, 'part type: "%s"\n' % self.type)
+        indebug(self.ui, 'part type: "%s"' % self.type)
         self.id = self._unpackheader(_fpartid)[0]
-        indebug(self.ui, 'part id: "%s"\n' % self.id)
+        indebug(self.ui, 'part id: "%s"' % self.id)
         # extract mandatory bit from type
         self.mandatory = (self.type != self.type.lower())
         self.type = self.type.lower()
         ## reading parameters
         # param count
         mancount, advcount = self._unpackheader(_fpartparamcount)
-        indebug(self.ui, 'part parameters: %i\n' % (mancount + advcount))
+        indebug(self.ui, 'part parameters: %i' % (mancount + advcount))
         # param size
         fparamsizes = _makefpartparamsizes(mancount + advcount)
         paramsizes = self._unpackheader(fparamsizes)