[PATCH] fastexport: fix data handling
Felipe Contreras
felipe.contreras at gmail.com
Thu Mar 2 20:13:05 UTC 2023
Commit messages are supposed to end on a newline, and blobs should not
be modified at all.
All data should be written as-is.
---
hgext/fastexport.py | 8 ++---
tests/test-fastexport.t | 73 +++++++++--------------------------------
2 files changed, 19 insertions(+), 62 deletions(-)
diff --git a/hgext/fastexport.py b/hgext/fastexport.py
index 738d75259a..a730b2ca7b 100644
--- a/hgext/fastexport.py
+++ b/hgext/fastexport.py
@@ -69,11 +69,9 @@ def convert_to_git_ref(branch):
return b"refs/heads/" + branch
-def write_data(buf, data, skip_newline):
+def write_data(buf, data):
buf.append(b"data %d\n" % len(data))
buf.append(data)
- if not skip_newline or data[-1:] != b"\n":
- buf.append(b"\n")
def export_commit(ui, repo, rev, marks, authormap):
@@ -103,7 +101,7 @@ def export_commit(ui, repo, rev, marks, authormap):
marks[filerev] = mark
data = filectx.data()
buf = [b"blob\n", b"mark :%d\n" % mark]
- write_data(buf, data, False)
+ write_data(buf, data)
ui.write(*buf, keepprogressbar=True)
del buf
@@ -122,7 +120,7 @@ def export_commit(ui, repo, rev, marks, authormap):
convert_to_git_date(ctx.date()),
),
]
- write_data(buf, ctx.description(), True)
+ write_data(buf, ctx.description() + b"\n")
if parents:
buf.append(b"from :%d\n" % marks[parents[0].hex()])
if len(parents) == 2:
diff --git a/tests/test-fastexport.t b/tests/test-fastexport.t
index 10af6465ed..b6218e651f 100644
--- a/tests/test-fastexport.t
+++ b/tests/test-fastexport.t
@@ -142,16 +142,14 @@
21
22
23
-
blob
mark :2
data 3
r0
-
commit refs/heads/default
mark :3
committer "debugbuilddag" <debugbuilddag> 0 +0000
- data 2
+ data 3
r0
M 644 :1 mf
M 644 :2 nf0
@@ -184,21 +182,18 @@
21
22
23
-
blob
mark :5
data 3
r1
-
blob
mark :6
data 3
r1
-
commit refs/heads/default
mark :7
committer "debugbuilddag" <debugbuilddag> 1 +0000
- data 2
+ data 3
r1
from :3
M 644 :4 mf
@@ -232,21 +227,18 @@
21
22
23
-
blob
mark :9
data 3
r2
-
blob
mark :10
data 3
r2
-
commit refs/heads/name1
mark :11
committer "debugbuilddag" <debugbuilddag> 2 +0000
- data 2
+ data 3
r2
from :7
M 644 :8 mf
@@ -280,21 +272,18 @@
21
22
23
-
blob
mark :13
data 3
r3
-
blob
mark :14
data 3
r3
-
commit refs/heads/name1
mark :15
committer "debugbuilddag" <debugbuilddag> 3 +0000
- data 2
+ data 3
r3
from :11
M 644 :12 mf
@@ -328,21 +317,18 @@
21
22
23
-
blob
mark :17
data 3
r4
-
blob
mark :18
data 3
r4
-
commit refs/heads/name1
mark :19
committer "debugbuilddag" <debugbuilddag> 4 +0000
- data 2
+ data 3
r4
from :15
M 644 :16 mf
@@ -376,21 +362,18 @@
21
22
23
-
blob
mark :21
data 3
r5
-
blob
mark :22
data 3
r5
-
commit refs/heads/name2
mark :23
committer "debugbuilddag" <debugbuilddag> 5 +0000
- data 2
+ data 3
r5
from :7
M 644 :20 mf
@@ -424,21 +407,18 @@
21
22
23
-
blob
mark :25
data 3
r6
-
blob
mark :26
data 3
r6
-
commit refs/heads/name2
mark :27
committer "debugbuilddag" <debugbuilddag> 6 +0000
- data 2
+ data 3
r6
from :23
M 644 :24 mf
@@ -472,21 +452,18 @@
21
22
23
-
blob
mark :29
data 3
r7
-
blob
mark :30
data 3
r7
-
commit refs/heads/name2
mark :31
committer "debugbuilddag" <debugbuilddag> 7 +0000
- data 2
+ data 3
r7
from :27
M 644 :28 mf
@@ -520,21 +497,18 @@
21
22
23
-
blob
mark :33
data 3
r8
-
blob
mark :34
data 3
r8
-
commit refs/heads/name2
mark :35
committer "debugbuilddag" <debugbuilddag> 8 +0000
- data 2
+ data 3
r8
from :31
M 644 :32 mf
@@ -568,21 +542,18 @@
21
22
23
-
blob
mark :37
data 3
r9
-
blob
mark :38
data 3
r9
-
commit refs/heads/both
mark :39
committer "debugbuilddag" <debugbuilddag> 9 +0000
- data 2
+ data 3
r9
from :35
merge :19
@@ -620,21 +591,18 @@
21
22
23
-
blob
mark :41
data 4
r10
-
blob
mark :42
data 4
r10
-
commit refs/heads/both
mark :43
committer "debugbuilddag" <debugbuilddag> 10 +0000
- data 3
+ data 4
r10
from :39
M 644 :40 mf
@@ -668,21 +636,18 @@
21
22 r11
23
-
blob
mark :45
data 4
r11
-
blob
mark :46
data 4
r11
-
commit refs/heads/both
mark :47
committer "debugbuilddag" <debugbuilddag> 11 +0000
- data 3
+ data 4
r11
from :43
M 644 :44 mf
@@ -692,7 +657,7 @@
commit refs/heads/both
mark :48
committer "debugbuilddag" <debugbuilddag> 12 +0230
- data 3
+ data 4
r12
from :43
D nf10
@@ -700,7 +665,7 @@
commit refs/heads/both
mark :49
committer "test" <test> 13 +0000
- data 13
+ data 14
debugbuilddag
from :47
merge :48
@@ -785,16 +750,14 @@
21
22
23
-
blob
mark :2
data 3
r0
-
commit refs/heads/default
mark :3
committer "debugbuilddag" <debugbuilddag> 0 +0000
- data 2
+ data 3
r0
M 644 :1 mf
M 644 :2 nf0
@@ -832,21 +795,18 @@
21
22
23
-
blob
mark :5
data 3
r1
-
blob
mark :6
data 3
r1
-
commit refs/heads/default
mark :7
committer "debugbuilddag" <debugbuilddag> 1 +0000
- data 2
+ data 3
r1
from :3
M 644 :4 mf
@@ -860,6 +820,5 @@
mark :50
data 4
foo
-
abort: Unable to parse user into person and email for revision 65a3f69b9b519de73d755472c1ab05990ab8a7f7
[255]
--
2.39.2
More information about the Mercurial-devel
mailing list