[Python-modules-commits] [python-fastimport] 01/05: Improve compatibility with python3.4.

Jelmer Vernooij jelmer at moszumanska.debian.org
Tue Apr 19 23:46:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

jelmer pushed a commit to branch upstream
in repository python-fastimport.

commit d85af24cc443806dbd81701d833e0e8258751193
Author: Jelmer Vernooij <jelmer at jelmer.uk>
Date:   Mon Apr 18 19:03:43 2016 +0000

    Improve compatibility with python3.4.
---
 fastimport/commands.py | 58 +++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/fastimport/commands.py b/fastimport/commands.py
index c8fb25e..c09314e 100644
--- a/fastimport/commands.py
+++ b/fastimport/commands.py
@@ -120,7 +120,7 @@ class BlobCommand(ImportCommand):
         self.lineno = lineno
         # Provide a unique id in case the mark is missing
         if mark is None:
-            self.id = b'@%d' % lineno
+            self.id = b'@' + ("%d" % lineno).encode('utf-8')
         else:
             self.id = b':' + mark
         self._binary = [b'data']
@@ -129,8 +129,9 @@ class BlobCommand(ImportCommand):
         if self.mark is None:
             mark_line = b''
         else:
-            mark_line = b"\nmark :%s" % self.mark
-        return b'blob%s\ndata %d\n%s' % (mark_line, len(self.data), self.data)
+            mark_line = b"\nmark :" + self.mark
+        return (b'blob' + mark_line + b'\n' +
+                ('data %d\n' % len(self.data)).encode('utf-8') + self.data)
 
 
 class CheckpointCommand(ImportCommand):
@@ -161,9 +162,9 @@ class CommitCommand(ImportCommand):
         self._binary = [b'file_iter']
         # Provide a unique id in case the mark is missing
         if mark is None:
-            self.id = b'@%d' % lineno
+            self.id = b'@' + ('%d' % lineno).encode('utf-8')
         else:
-            self.id = b':%s' % mark
+            self.id = b':' + mark
 
     def copy(self, **kwargs):
         if not isinstance(self.file_iter, list):
@@ -192,30 +193,30 @@ class CommitCommand(ImportCommand):
         if self.mark is None:
             mark_line = b''
         else:
-            mark_line = b'\nmark :%s' % self.mark
+            mark_line = b'\nmark :' + self.mark
         if self.author is None:
             author_section = b''
         else:
-            author_section = b'\nauthor %s' % format_who_when(self.author)
+            author_section = b'\nauthor ' + format_who_when(self.author)
             if use_features and self.more_authors:
                 for author in self.more_authors:
-                    author_section += b'\nauthor %s' % format_who_when(author)
+                    author_section += b'\nauthor ' + format_who_when(author)
 
-        committer = b'committer %s' % format_who_when(self.committer)
+        committer = b'committer ' + format_who_when(self.committer)
 
         if self.message is None:
             msg_section = b''
         else:
             msg = self.message
-            msg_section = b'\ndata %d\n%s' % (len(msg), msg)
+            msg_section = ('\ndata %d\n' % len(msg)).encode('ascii') + msg
         if self.from_ is None:
             from_line = b''
         else:
-            from_line = b'\nfrom %s' % self.from_
+            from_line = b'\nfrom ' + self.from_
         if self.merges is None:
             merge_lines = b''
         else:
-            merge_lines = b''.join([b'\nmerge %s' % (m,)
+            merge_lines = b''.join([b'\nmerge ' + m
                 for m in self.merges])
         if use_features and self.properties:
             property_lines = []
@@ -270,8 +271,8 @@ class FeatureCommand(ImportCommand):
         if self.value is None:
             value_text = b''
         else:
-            value_text = b'=%s' % self.value
-        return b'feature %s%s' % (self.feature_name, value_text)
+            value_text = b'=' + self.value
+        return b'feature ' + self.feature_name + value_text
 
 
 class ProgressCommand(ImportCommand):
@@ -281,7 +282,7 @@ class ProgressCommand(ImportCommand):
         self.message = message
 
     def __bytes__(self):
-        return b'progress %s' % (self.message,)
+        return b'progress ' + self.message
 
 
 class ResetCommand(ImportCommand):
@@ -378,7 +379,8 @@ class FileModifyCommand(FileCommand):
             dataref = b'%s' % (self.dataref,)
         path = format_path(self.path)
 
-        return b'M %s %s %s%s' % (self._format_mode(self.mode), dataref, path, datastr)
+        return b' '.join(
+            [b'M', self._format_mode(self.mode), dataref, path + datastr])
 
 
 class FileDeleteCommand(FileCommand):
@@ -388,7 +390,7 @@ class FileDeleteCommand(FileCommand):
         self.path = check_path(path)
 
     def __bytes__(self):
-        return b'D %s' % (format_path(self.path),)
+        return b' '.join([b'D', format_path(self.path)])
 
 
 class FileCopyCommand(FileCommand):
@@ -399,9 +401,9 @@ class FileCopyCommand(FileCommand):
         self.dest_path = check_path(dest_path)
 
     def __bytes__(self):
-        return b'C %s %s' % (
+        return b' '.join([b'C',
             format_path(self.src_path, quote_spaces=True),
-            format_path(self.dest_path))
+            format_path(self.dest_path)])
 
 
 class FileRenameCommand(FileCommand):
@@ -412,9 +414,10 @@ class FileRenameCommand(FileCommand):
         self.new_path = check_path(new_path)
 
     def __bytes__(self):
-        return b'R %s %s' % (
+        return b' '.join([
+            b'R',
             format_path(self.old_path, quote_spaces=True),
-            format_path(self.new_path)
+            format_path(self.new_path)]
         )
 
 
@@ -436,9 +439,8 @@ class NoteModifyCommand(FileCommand):
         self._binary = ['data']
 
     def __bytes__(self):
-        return b'N inline :%s\ndata %d\n%s' % (
-            self.from_, len(self.data), self.data
-        )
+        return (b'N inline :' + self.from_ +
+                ('\ndata %d\n'% len(self.data)).encode('ascii') + self.data)
 
 
 def check_path(path):
@@ -482,7 +484,7 @@ def format_who_when(fields):
         offset_sign = b'+'
     offset_hours = offset // 3600
     offset_minutes = offset // 60 - offset_hours * 60
-    offset_str = b'%s%02d%02d' % (offset_sign, offset_hours, offset_minutes)
+    offset_str = offset_sign + ('%02d%02d' % (offset_hours, offset_minutes)).encode('ascii')
     name = fields[0]
 
     if name == b'':
@@ -496,9 +498,7 @@ def format_who_when(fields):
 
     email = utf8_bytes_string(email)
 
-    result = b'%s%s<%s> %d %s' % (name, sep, email, fields[2], offset_str)
-
-    return result
+    return b''.join((name, sep, b'<', email, b'> ', ("%d" % fields[2]).encode('ascii'), b' ', offset_str))
 
 
 def format_property(name, value):
@@ -512,6 +512,6 @@ def format_property(name, value):
             utf8_name, len(utf8_value), utf8_value
         )
     else:
-        result = b'property %s' % (utf8_name,)
+        result = b'property ' + utf8_name
 
     return result

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-fastimport.git



More information about the Python-modules-commits mailing list