[PATCH 3 of 7 main-line-of-works (28 more patches to go)]] bundle2: handle new line in 'indebug' function

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu May 28 11:53:14 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1432706499 25200
#      Tue May 26 23:01:39 2015 -0700
# Node ID 7660759a9bdb444daaa104c30496f4eb0a350cb8
# Parent  c25edb87d38eb9a99e526ab9af0a550358c54cd6
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.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -177,11 +177,11 @@ def outdebug(ui, message):
     """debug regarding output stream (bundling)"""
     ui.debug('bundle2-output: %s\n' % message)
 
 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"""
     if _parttypeforbidden.search(parttype):
         raise ValueError(parttype)
@@ -348,21 +348,21 @@ def _processpart(op, part):
     try:
         try:
             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)
                 unknownparams.sort()
                 raise error.UnsupportedPartError(parttype=part.type,
                                                params=unknownparams)
         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
         # risk catching KeyErrors from anything other than the
         # parthandlermapping lookup (any KeyError raised by handler()
@@ -561,11 +561,11 @@ def getunbundler(ui, fp, header=None):
         raise util.Abort(_('not a Mercurial bundle'))
     unbundlerclass = formatmap.get(version)
     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):
     """interpret a bundle2 stream
 
@@ -578,11 +578,11 @@ class unbundle20(unpackermixin):
         super(unbundle20, self).__init__(fp)
 
     @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:
             raise error.BundleValueError('negative bundle param size: %i'
                                          % paramssize)
@@ -611,37 +611,37 @@ class unbundle20(unpackermixin):
         if name[0] not in string.letters:
             raise ValueError('non letter first character: %r' % name)
         # 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,))
 
 
     def iterparts(self):
         """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
 
         returns None if empty"""
         headersize = self._unpack(_fpartheadersize)[0]
         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
 
     def compressed(self):
@@ -829,14 +829,14 @@ class interrupthandler(unpackermixin):
         if headersize:
             return self._readexact(headersize)
         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)
         _processpart(op, part)
 
@@ -916,11 +916,11 @@ class unbundlepart(unpackermixin):
                    'Unknown chunk %d' % chunknum
             super(unbundlepart, self).seek(self._chunkindex[chunknum][1])
 
         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
                 # single part and process it.
                 interrupthandler(self.ui, self._fp)()
@@ -934,11 +934,11 @@ class unbundlepart(unpackermixin):
                 if chunknum == len(self._chunkindex):
                     self._chunkindex.append((pos,
                                              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'''
         for chunk, (ppos, fpos) in enumerate(self._chunkindex):
             if ppos == pos:
@@ -949,20 +949,20 @@ class unbundlepart(unpackermixin):
 
     def _readheader(self):
         """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)
         # make it a list of couple again
         paramsizes = zip(paramsizes[::2], paramsizes[1::2])


More information about the Mercurial-devel mailing list