changeset 50401:dd42156b6441

fastexport: rework newline logic Newlines should only be added when otherwise the stream would look weird without them (on blobs), therefore they are the exception. Flip the logic so they are added, not skipped.
author Felipe Contreras <felipe.contreras@gmail.com>
date Thu, 09 Mar 2023 13:02:13 -0600
parents 95acba2c29f6
children c5e93c915ab6
files hgext/fastexport.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/fastexport.py	Mon Mar 06 11:27:57 2023 +0000
+++ b/hgext/fastexport.py	Thu Mar 09 13:02:13 2023 -0600
@@ -69,10 +69,10 @@
     return b"refs/heads/" + branch
 
 
-def write_data(buf, data, skip_newline):
+def write_data(buf, data, add_newline=False):
     buf.append(b"data %d\n" % len(data))
     buf.append(data)
-    if not skip_newline or data[-1:] != b"\n":
+    if add_newline or data[-1:] != b"\n":
         buf.append(b"\n")
 
 
@@ -103,7 +103,7 @@
             marks[filerev] = mark
             data = filectx.data()
             buf = [b"blob\n", b"mark :%d\n" % mark]
-            write_data(buf, data, False)
+            write_data(buf, data, True)
             ui.write(*buf, keepprogressbar=True)
             del buf
 
@@ -122,7 +122,7 @@
             convert_to_git_date(ctx.date()),
         ),
     ]
-    write_data(buf, ctx.description(), True)
+    write_data(buf, ctx.description())
     if parents:
         buf.append(b"from :%d\n" % marks[parents[0].hex()])
     if len(parents) == 2: