Commit 1eb56978 authored by Kirill Smelkov's avatar Kirill Smelkov

X got python quoting right

parent fa3a552c
......@@ -29,6 +29,7 @@ import (
"log"
"os"
"strconv"
"strings"
"unicode/utf8"
"../../../../storage/fs1"
......@@ -36,9 +37,7 @@ import (
"lab.nexedi.com/kirr/go123/mem"
)
// pyQuote quotes string the way python would do it
// specifically quote char is ' (not " as in go)
// XXX s = 'a\'bc'; print repr(s) -> "a'bc" (not 'a\'bc' <- XXX fix this
// pyQuote quotes string the way python repr(str) would do it
func pyQuote(s string) string {
out := pyQuoteBytes(mem.Bytes(s))
return mem.String(out)
......@@ -47,19 +46,52 @@ func pyQuote(s string) string {
func pyQuoteBytes(b []byte) []byte {
s := mem.String(b)
buf := make([]byte, 0, len(s))
buf = append(buf, '\'')
// smartquotes: choose ' or " as quoting character
// https://github.com/python/cpython/blob/v2.7.13-116-g1aa1803b3d/Objects/stringobject.c#L947
quote := byte('\'')
noquote := byte('"')
if strings.ContainsRune(s, '\'') && !strings.ContainsRune(s, '"') {
quote, noquote = noquote, quote
}
buf = append(buf, quote)
for i, r := range s {
if r == utf8.RuneError {
buf = append(buf, []byte(fmt.Sprintf("\\x%0x", s[i]))...)
} else {
rq := strconv.QuoteRune(r) // "'\x01'"
rq = rq[1:len(rq)-1] // "\x01"
buf = append(buf, rq...)
switch r {
case utf8.RuneError:
buf = append(buf, []byte(fmt.Sprintf("\\x%02x", s[i]))...)
case '\\', rune(quote):
buf = append(buf, '\\', byte(r))
case rune(noquote):
buf = append(buf, noquote)
// NOTE python converts to \<letter> only \t \n \r (not e.g. \v)
// https://github.com/python/cpython/blob/v2.7.13-116-g1aa1803b3d/Objects/stringobject.c#L963
case '\t':
buf = append(buf, `\t`...)
case '\n':
buf = append(buf, `\n`...)
case '\r':
buf = append(buf, `\r`...)
default:
switch {
case r < ' ':
// we already converted to \<letter> what python represents as such above
buf = append(buf, []byte(fmt.Sprintf("\\x%02x", s[i]))...)
default:
// we aleady handled ', " and (< ' ') above, so now it
// should be safe to reuse strconv.QuoteRune
rq := strconv.QuoteRune(r) // "'\x01'"
rq = rq[1:len(rq)-1] // "\x01"
buf = append(buf, rq...)
}
}
}
buf = append(buf, '\'')
buf = append(buf, quote)
return buf
}
......@@ -141,7 +173,11 @@ func fsDump(w io.Writer, path string, ntxn int) (err error) {
// print information about read txn record
_, err = fmt.Fprintf(w, "%s: hash=%x\nuser=%s description=%s length=%d offset=%d (+%d)\n\n",
txnh.Tid.Time(), sha1.Sum(data),
// fstail.py uses repr to print user/description:
// https://github.com/zopefoundation/ZODB/blob/5.2.0-4-g359f40ec7/src/ZODB/scripts/fstail.py#L39
pyQuoteBytes(txnh.User), pyQuoteBytes(txnh.Description),
// NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length
txnh.Len - 8,
txnh.Pos, txnh.HeaderLen())
......@@ -157,7 +193,7 @@ func fsDump(w io.Writer, path string, ntxn int) (err error) {
func main() {
ntxn := 10
usage := func() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr,
`fstail [options] <storage>
Dump transactions from a FileStorage in reverse order
......@@ -171,13 +207,12 @@ Dump transactions from a FileStorage in reverse order
`, ntxn)
}
flag.Usage = usage
flag.IntVar(&ntxn, "n", ntxn, "output the last <N> transactions")
flag.Parse()
argv := flag.Args()
if len(argv) < 1 {
usage()
flag.Usage()
os.Exit(2) // XXX recheck it is same as from flag.Parse on -zzz
}
storPath := argv[0]
......
1979-01-03 21:01:31.300002: hash=9176cad01fe2751a2317912476da043f2cd27085
user="root1\nYour\nRoyal\nMagesty' " description='delete 1\nalpha beta gamma\'delta"lambda\n\nqqq ...' length=206 offset=11948 (+156)
1979-01-03 21:01:31.300002: hash=132dacc98500dc2f6d3ed7339fb9f8e820719477
user="root1\nYour\nRoyal\nMagesty' \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" description='delete 1\nalpha beta gamma\'delta"lambda\n\nqqq ...' length=238 offset=11980 (+188)
1979-01-03 21:01:30.200002: hash=4c2bcec885530156e134f089e7255a0ad1f2eab0
user='' description='predelete 6' length=362 offset=11578 (+34)
1979-01-03 21:01:30.200002: hash=d783be6d164baac8786e235590903bc67e949b61
user='' description='predelete 6' length=362 offset=11610 (+34)
1979-01-03 21:01:29.100002: hash=fd3148ac612b6ec793747165c73ce236a3b61702
user='root1.1\nYour\nMagesty ' description='undo 1.1\nmore detailed description\n\nzzz ...\t\t' length=208 offset=11362 (+158)
1979-01-03 21:01:29.100002: hash=7ec0737f615cf705cebfbda1a0b89412adb52d0a
user='root1.1\nYour\nMagesty ' description='undo 1.1\nmore detailed description\n\nzzz ...\t\t' length=208 offset=11394 (+158)
1979-01-03 21:01:28.000002: hash=ef9928d3049ad902a5d98293d46358cea8f44319
user='root1.0\nYour\nMagesty ' description='undo 1.0\nmore detailed description\n\nzzz ...\t' length=207 offset=11147 (+157)
1979-01-03 21:01:28.000002: hash=c2fcc684a7916bdcce0a8ba9cb9c9391ba13654d
user='root1.0\nYour\nMagesty ' description='undo 1.0\nmore detailed description\n\nzzz ...\t' length=207 offset=11179 (+157)
1979-01-03 21:01:25.800002: hash=bc4c742d2821d463ffad5348f6c86d4ed44996cf
user='user1.24' description='step 1.24' length=165 offset=10974 (+93)
1979-01-03 21:01:25.800002: hash=392f2216c2c2ae37d1a396bfe0394d85aad0f1dc
user='user1.24' description='step 1.24' length=165 offset=11006 (+93)
1979-01-03 21:01:24.700002: hash=ad2bfa76c1c7288f99831397715d120a84ac3e63
user='user1.23' description='step 1.23' length=165 offset=10801 (+93)
1979-01-03 21:01:24.700002: hash=89f5e0ad5af7fa46d418412ecb5ccf8ec5d550f4
user='user1.23' description='step 1.23' length=165 offset=10833 (+93)
1979-01-03 21:01:23.600002: hash=722921c9dd036f270f505d4e1645a63b62f6bac1
user='user1.22' description='step 1.22' length=165 offset=10628 (+93)
1979-01-03 21:01:23.600002: hash=422d4514a5a0cf08afc427b2a589264fa798f0fd
user='user1.22' description='step 1.22' length=165 offset=10660 (+93)
1979-01-03 21:01:22.500002: hash=f22d4cdd01d17a66d53e8727b1305c227983b194
user='user1.21' description='step 1.21' length=165 offset=10455 (+93)
1979-01-03 21:01:22.500002: hash=11ecff1984ddf48e3da386bc4d689900fb70c9b1
user='user1.21' description='step 1.21' length=165 offset=10487 (+93)
1979-01-03 21:01:21.400002: hash=e3c412c26b6522c046bdfe630eef32451b50ba69
user='user1.20' description='step 1.20' length=165 offset=10282 (+93)
1979-01-03 21:01:21.400002: hash=1057ae69f5f40b49fb610f8672698ecd31dd3501
user='user1.20' description='step 1.20' length=165 offset=10314 (+93)
1979-01-03 21:01:20.300002: hash=54cdd59a7131c0784bb3236471d857ed6f33f9b9
user='user1.19' description='step 1.19' length=165 offset=10109 (+93)
1979-01-03 21:01:20.300002: hash=916cb146cafdc4094f57ec64b32256195e6bd0b5
user='user1.19' description='step 1.19' length=165 offset=10141 (+93)
1979-01-03 21:01:19.200002: hash=20a4abf3c8a0984798374af5ed890e2910f46265
user='user1.18' description='step 1.18' length=165 offset=9936 (+93)
1979-01-03 21:01:19.200002: hash=422ddafb8ba35869bb887c583cb15cb35ee90d0a
user='user1.18' description='step 1.18' length=165 offset=9968 (+93)
1979-01-03 21:01:18.100002: hash=a7c66e66a6e25cafe9b046b5a41993287ba3e296
user='user1.17' description='step 1.17' length=165 offset=9763 (+93)
1979-01-03 21:01:18.100002: hash=5c0b9f3fc2cb8da9de23109cbb05b47600209a3f
user='user1.17' description='step 1.17' length=165 offset=9795 (+93)
1979-01-03 21:01:17.000002: hash=a69f094230ca875a963524c93a35d23f0687308d
user='user1.16' description='step 1.16' length=165 offset=9590 (+93)
1979-01-03 21:01:17.000002: hash=7bc7b122bc5b19fc5956ea1fadff26bddd6d76ef
user='user1.16' description='step 1.16' length=165 offset=9622 (+93)
1979-01-03 21:01:15.900002: hash=96316e0682da99e24c5d587b4bd4d2f3150eea8b
user='user1.15' description='step 1.15' length=165 offset=9417 (+93)
1979-01-03 21:01:15.900002: hash=c883974a78a88618132cf3152d29db1ee3626da9
user='user1.15' description='step 1.15' length=165 offset=9449 (+93)
1979-01-03 21:01:14.800002: hash=da20e7ad9c0f55e7576dba5ffd9912c37d059232
user='user1.14' description='step 1.14' length=165 offset=9244 (+93)
1979-01-03 21:01:14.800002: hash=7f3e20b9ba460593174bb9f1a9901aa6f8b559e2
user='user1.14' description='step 1.14' length=165 offset=9276 (+93)
1979-01-03 21:01:13.700002: hash=877241dc4a5f14d24a7779917310332f6c2e414e
user='user1.13' description='step 1.13' length=165 offset=9071 (+93)
1979-01-03 21:01:13.700002: hash=3818e96310cf6e6b67709fc486858fc223113be5
user='user1.13' description='step 1.13' length=165 offset=9103 (+93)
1979-01-03 21:01:12.600002: hash=321ea792b7e67ac9339de238e817ca639d7f42ec
user='user1.12' description='step 1.12' length=165 offset=8898 (+93)
1979-01-03 21:01:12.600002: hash=97a27eaa6771b0fc8a0473251ef2f06a65866c08
user='user1.12' description='step 1.12' length=165 offset=8930 (+93)
1979-01-03 21:01:11.500002: hash=6b64527e3ba109266a8d68321147d54af8d6edc7
user='user1.11' description='step 1.11' length=165 offset=8725 (+93)
1979-01-03 21:01:11.500002: hash=ca201ecaf94a4809b6c87b9c22e827cc8e901617
user='user1.11' description='step 1.11' length=165 offset=8757 (+93)
1979-01-03 21:01:10.400002: hash=a5db043429fc63d48df1922ab60f3e6990d3561c
user='user1.10' description='step 1.10' length=165 offset=8552 (+93)
1979-01-03 21:01:10.400002: hash=f9cd2cadaef25f9854e589965d5a6dfee9a42b2e
user='user1.10' description='step 1.10' length=165 offset=8584 (+93)
1979-01-03 21:01:09.300001: hash=200139e7913a7ff53a34c6f5484b92128b246cde
user='user1.9' description='step 1.9' length=162 offset=8382 (+91)
1979-01-03 21:01:09.300001: hash=3cc0c694df5aaf607331a3b5f0f7246353d2cea5
user='user1.9' description='step 1.9' length=162 offset=8414 (+91)
1979-01-03 21:01:08.200001: hash=39dfd11d1f24fb97387aeabf2a013f6ede6385dd
user='user1.8' description='step 1.8' length=162 offset=8212 (+91)
1979-01-03 21:01:08.200001: hash=a2c2c7e3fd68f0f464e8df2e2d657403ebe998b1
user='user1.8' description='step 1.8' length=162 offset=8244 (+91)
1979-01-03 21:01:07.100001: hash=9f7327cd475602bca99bf085aabf6051f2573313
user='user1.7' description='step 1.7' length=162 offset=8042 (+91)
1979-01-03 21:01:07.100001: hash=8aaae32a640e94ec46c56604ef727d819174dadf
user='user1.7' description='step 1.7' length=162 offset=8074 (+91)
1979-01-03 21:01:06.000001: hash=735edd1e61556098b0268dee9df1cae6a66aa938
user='user1.6' description='step 1.6' length=162 offset=7872 (+91)
1979-01-03 21:01:06.000001: hash=d6a491262e79be892f77442401851e97057a5e1b
user='user1.6' description='step 1.6' length=162 offset=7904 (+91)
1979-01-03 21:01:04.900001: hash=43863e7c4b4fb3f1bd400248d71fabbdac9456b6
user='user1.5' description='step 1.5' length=162 offset=7702 (+91)
1979-01-03 21:01:04.900001: hash=467a7e8eb8c9c42d6dd07ce66869a6b549864899
user='user1.5' description='step 1.5' length=162 offset=7734 (+91)
1979-01-03 21:01:03.800001: hash=22ee061f2372fd74d03cf5dd54197bc3aa12a816
user='user1.4' description='step 1.4' length=162 offset=7532 (+91)
1979-01-03 21:01:03.800001: hash=5e3e9b8032ac4a1343b115fbfb662bdc5c5778e4
user='user1.4' description='step 1.4' length=162 offset=7564 (+91)
1979-01-03 21:01:02.700001: hash=be00cfff67f8f186cce0efb4be7af5525a8fdda7
user='user1.3' description='step 1.3' length=162 offset=7362 (+91)
1979-01-03 21:01:02.700001: hash=cef316831ff36f956440a7586df1a0170e7b8111
user='user1.3' description='step 1.3' length=162 offset=7394 (+91)
1979-01-03 21:01:01.600001: hash=152e5811cc260c0e9c28cf6bc0c5fb5c147b4daa
user='user1.2' description='step 1.2' length=162 offset=7192 (+91)
1979-01-03 21:01:01.600001: hash=9844714205a885699405eb241cdb65f8bc08a503
user='user1.2' description='step 1.2' length=162 offset=7224 (+91)
1979-01-03 21:01:00.500001: hash=16e51f130683d896e8d182ebdd3bb80ae35d6050
user='user1.1' description='step 1.1' length=162 offset=7022 (+91)
1979-01-03 21:01:00.500001: hash=aa5020c400ecf153ec97c3565fb2948641830fd0
user='user1.1' description='step 1.1' length=162 offset=7054 (+91)
1979-01-03 21:00:59.400001: hash=17453ac2d8f8044d959f763516b56eda268e96ad
user='user1.0' description='step 1.0' length=162 offset=6852 (+91)
1979-01-03 21:00:59.400001: hash=3781d0578e07d668c46a4d446425c37924261501
user='user1.0' description='step 1.0' length=162 offset=6884 (+91)
1979-01-03 21:00:45.100001: hash=51db603ba9898da20dbe162dd20e4a76aeacbfeb
user="root0\nYour\nRoyal\nMagesty' " description='delete 0\nalpha beta gamma\'delta"lambda\n\nqqq ...' length=206 offset=6638 (+156)
user="root0\nYour\nRoyal\nMagesty' \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" description='delete 0\nalpha beta gamma\'delta"lambda\n\nqqq ...' length=238 offset=6638 (+188)
1979-01-03 21:00:44.000001: hash=469f380f59f9a72dae5ee6351fa2e38efb170d86
user='' description='predelete 7' length=362 offset=6268 (+34)
......
......@@ -33,6 +33,8 @@ def escapeqq(s):
# we don't want ' to be escaped
for _ in s.split("'"):
# this escape almost everything except " character
# NOTE string_escape does not do smartquotes and always uses ' for quoting
# (repr(str) is the same except it does smartquoting picking ' or " automatically)
q = _.encode("string_escape")
q = q.replace('"', r'\"')
outv.append(q)
......@@ -154,7 +156,8 @@ def main():
# Get serial via history.
obj_tid_lastchange = db.history(obj._p_oid)[0]['tid']
txn = precommit(u"root%i\nYour\nRoyal\nMagesty' " % i,
txn = precommit(u"root%i\nYour\nRoyal\nMagesty' " % i +
''.join(chr(_) for _ in range(32)), # <- NOTE all control characters
u"delete %i\nalpha beta gamma'delta\"lambda\n\nqqq ..." % i,
ext("delete %s" % unpack64(obj._p_oid)))
stor.tpc_begin(txn)
......
......@@ -3,18 +3,18 @@ package fs1
import "../../zodb"
const _1fs_indexTopPos = 12162
const _1fs_indexTopPos = 12226
var _1fs_indexEntryv = [...]indexEntry{
{ 0, 11612},
{ 1, 10029},
{ 2, 9683},
{ 3, 10548},
{ 4, 7283},
{ 5, 11520},
{ 6, 12104},
{ 7, 6794},
{ 8, 8991},
{ 9, 11870},
{ 0, 11644},
{ 1, 10061},
{ 2, 9715},
{ 3, 10580},
{ 4, 7315},
{ 5, 11552},
{ 6, 12168},
{ 7, 6826},
{ 8, 9023},
{ 9, 11902},
}
var _1fs_dbEntryv = [...]dbEntry{
......@@ -996,11 +996,11 @@ var _1fs_dbEntryv = [...]dbEntry{
TxnHeader{
Pos: 6638,
LenPrev: 370,
Len: 214,
Len: 246,
TxnInfo: zodb.TxnInfo{
Tid: 0x0285cbacc06d3a4c,
Status: ' ',
User: []byte("root0\nYour\nRoyal\nMagesty' "),
User: []byte("root0\nYour\nRoyal\nMagesty' \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"),
Description: []byte("delete 0\nalpha beta gamma'delta\"lambda\n\nqqq ..."),
Extension: []byte("}q\x01(U\tx-cookieEU\x05ZM3QZU\x0bx-generatorq\x02U\x13zodb/py2 (delete 7)u."),
},
......@@ -1009,7 +1009,7 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 6794,
Pos: 6826,
Oid: 7,
Tid: 0x0285cbacc06d3a4c,
PrevRevPos: 5995,
......@@ -1024,8 +1024,8 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 6852,
LenPrev: 214,
Pos: 6884,
LenPrev: 246,
Len: 170,
TxnInfo: zodb.TxnInfo{
Tid: 0x0285cbacfd70a433,
......@@ -1039,11 +1039,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 6943,
Pos: 6975,
Oid: 8,
Tid: 0x0285cbacfd70a433,
PrevRevPos: 6560,
TxnPos: 6852,
TxnPos: 6884,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04c1.0q\x02."),
......@@ -1054,7 +1054,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 7022,
Pos: 7054,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1069,11 +1069,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 7113,
Pos: 7145,
Oid: 6,
Tid: 0x0285cbad02222280,
PrevRevPos: 3944,
TxnPos: 7022,
TxnPos: 7054,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04e1.1q\x02."),
......@@ -1084,7 +1084,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 7192,
Pos: 7224,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1099,11 +1099,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 7283,
Pos: 7315,
Oid: 4,
Tid: 0x0285cbad06d3a0cc,
PrevRevPos: 4463,
TxnPos: 7192,
TxnPos: 7224,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04b1.2q\x02."),
......@@ -1114,7 +1114,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 7362,
Pos: 7394,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1129,11 +1129,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 7453,
Pos: 7485,
Oid: 3,
Tid: 0x0285cbad0b851f19,
PrevRevPos: 6210,
TxnPos: 7362,
TxnPos: 7394,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04g1.3q\x02."),
......@@ -1144,7 +1144,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 7532,
Pos: 7564,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1159,11 +1159,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 7623,
Pos: 7655,
Oid: 3,
Tid: 0x0285cbad10369d66,
PrevRevPos: 7453,
TxnPos: 7532,
PrevRevPos: 7485,
TxnPos: 7564,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04g1.4q\x02."),
......@@ -1174,7 +1174,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 7702,
Pos: 7734,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1189,11 +1189,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 7793,
Pos: 7825,
Oid: 8,
Tid: 0x0285cbad14e81bb3,
PrevRevPos: 6943,
TxnPos: 7702,
PrevRevPos: 6975,
TxnPos: 7734,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04c1.5q\x02."),
......@@ -1204,7 +1204,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 7872,
Pos: 7904,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1219,11 +1219,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 7963,
Pos: 7995,
Oid: 1,
Tid: 0x0285cbad19999a00,
PrevRevPos: 3425,
TxnPos: 7872,
TxnPos: 7904,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04f1.6q\x02."),
......@@ -1234,7 +1234,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 8042,
Pos: 8074,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1249,11 +1249,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 8133,
Pos: 8165,
Oid: 2,
Tid: 0x0285cbad1e4b184c,
PrevRevPos: 4982,
TxnPos: 8042,
TxnPos: 8074,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04d1.7q\x02."),
......@@ -1264,7 +1264,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 8212,
Pos: 8244,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1279,11 +1279,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 8303,
Pos: 8335,
Oid: 8,
Tid: 0x0285cbad22fc9699,
PrevRevPos: 7793,
TxnPos: 8212,
PrevRevPos: 7825,
TxnPos: 8244,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04c1.8q\x02."),
......@@ -1294,7 +1294,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 8382,
Pos: 8414,
LenPrev: 170,
Len: 170,
TxnInfo: zodb.TxnInfo{
......@@ -1309,11 +1309,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 8473,
Pos: 8505,
Oid: 8,
Tid: 0x0285cbad27ae14e6,
PrevRevPos: 8303,
TxnPos: 8382,
PrevRevPos: 8335,
TxnPos: 8414,
DataLen: 29,
},
[]byte("c__main__\nObject\nq\x01.U\x04c1.9q\x02."),
......@@ -1324,7 +1324,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 8552,
Pos: 8584,
LenPrev: 170,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1339,11 +1339,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 8645,
Pos: 8677,
Oid: 6,
Tid: 0x0285cbad2c5f9333,
PrevRevPos: 7113,
TxnPos: 8552,
PrevRevPos: 7145,
TxnPos: 8584,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05e1.10q\x02."),
......@@ -1354,7 +1354,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 8725,
Pos: 8757,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1369,11 +1369,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 8818,
Pos: 8850,
Oid: 5,
Tid: 0x0285cbad31111180,
PrevRevPos: 4636,
TxnPos: 8725,
TxnPos: 8757,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05a1.11q\x02."),
......@@ -1384,7 +1384,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 8898,
Pos: 8930,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1399,11 +1399,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 8991,
Pos: 9023,
Oid: 8,
Tid: 0x0285cbad35c28fcc,
PrevRevPos: 8473,
TxnPos: 8898,
PrevRevPos: 8505,
TxnPos: 8930,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05c1.12q\x02."),
......@@ -1414,7 +1414,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 9071,
Pos: 9103,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1429,11 +1429,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 9164,
Pos: 9196,
Oid: 6,
Tid: 0x0285cbad3a740e19,
PrevRevPos: 8645,
TxnPos: 9071,
PrevRevPos: 8677,
TxnPos: 9103,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05e1.13q\x02."),
......@@ -1444,7 +1444,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 9244,
Pos: 9276,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1459,11 +1459,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 9337,
Pos: 9369,
Oid: 3,
Tid: 0x0285cbad3f258c66,
PrevRevPos: 7623,
TxnPos: 9244,
PrevRevPos: 7655,
TxnPos: 9276,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05g1.14q\x02."),
......@@ -1474,7 +1474,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 9417,
Pos: 9449,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1489,11 +1489,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 9510,
Pos: 9542,
Oid: 3,
Tid: 0x0285cbad43d70ab3,
PrevRevPos: 9337,
TxnPos: 9417,
PrevRevPos: 9369,
TxnPos: 9449,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05g1.15q\x02."),
......@@ -1504,7 +1504,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 9590,
Pos: 9622,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1519,11 +1519,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 9683,
Pos: 9715,
Oid: 2,
Tid: 0x0285cbad48888900,
PrevRevPos: 8133,
TxnPos: 9590,
PrevRevPos: 8165,
TxnPos: 9622,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05d1.16q\x02."),
......@@ -1534,7 +1534,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 9763,
Pos: 9795,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1549,11 +1549,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 9856,
Pos: 9888,
Oid: 3,
Tid: 0x0285cbad4d3a074c,
PrevRevPos: 9510,
TxnPos: 9763,
PrevRevPos: 9542,
TxnPos: 9795,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05g1.17q\x02."),
......@@ -1564,7 +1564,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 9936,
Pos: 9968,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1579,11 +1579,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 10029,
Pos: 10061,
Oid: 1,
Tid: 0x0285cbad51eb8599,
PrevRevPos: 7963,
TxnPos: 9936,
PrevRevPos: 7995,
TxnPos: 9968,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05f1.18q\x02."),
......@@ -1594,7 +1594,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 10109,
Pos: 10141,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1609,11 +1609,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 10202,
Pos: 10234,
Oid: 5,
Tid: 0x0285cbad569d03e6,
PrevRevPos: 8818,
TxnPos: 10109,
PrevRevPos: 8850,
TxnPos: 10141,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05a1.19q\x02."),
......@@ -1624,7 +1624,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 10282,
Pos: 10314,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1639,11 +1639,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 10375,
Pos: 10407,
Oid: 3,
Tid: 0x0285cbad5b4e8233,
PrevRevPos: 9856,
TxnPos: 10282,
PrevRevPos: 9888,
TxnPos: 10314,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05g1.20q\x02."),
......@@ -1654,7 +1654,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 10455,
Pos: 10487,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1669,11 +1669,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 10548,
Pos: 10580,
Oid: 3,
Tid: 0x0285cbad60000080,
PrevRevPos: 10375,
TxnPos: 10455,
PrevRevPos: 10407,
TxnPos: 10487,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05g1.21q\x02."),
......@@ -1684,7 +1684,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 10628,
Pos: 10660,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1699,11 +1699,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 10721,
Pos: 10753,
Oid: 6,
Tid: 0x0285cbad64b17ecc,
PrevRevPos: 9164,
TxnPos: 10628,
PrevRevPos: 9196,
TxnPos: 10660,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05e1.22q\x02."),
......@@ -1714,7 +1714,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 10801,
Pos: 10833,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1729,11 +1729,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 10894,
Pos: 10926,
Oid: 5,
Tid: 0x0285cbad6962fd19,
PrevRevPos: 10202,
TxnPos: 10801,
PrevRevPos: 10234,
TxnPos: 10833,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05a1.23q\x02."),
......@@ -1744,7 +1744,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 10974,
Pos: 11006,
LenPrev: 173,
Len: 173,
TxnInfo: zodb.TxnInfo{
......@@ -1759,11 +1759,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 11067,
Pos: 11099,
Oid: 5,
Tid: 0x0285cbad6e147b66,
PrevRevPos: 10894,
TxnPos: 10974,
PrevRevPos: 10926,
TxnPos: 11006,
DataLen: 30,
},
[]byte("c__main__\nObject\nq\x01.U\x05a1.24q\x02."),
......@@ -1774,7 +1774,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 11147,
Pos: 11179,
LenPrev: 173,
Len: 215,
TxnInfo: zodb.TxnInfo{
......@@ -1789,14 +1789,14 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 11304,
Pos: 11336,
Oid: 6,
Tid: 0x0285cbad77777800,
PrevRevPos: 10721,
TxnPos: 11147,
PrevRevPos: 10753,
TxnPos: 11179,
DataLen: 0,
},
[]byte("\x00\x00\x00\x00\x00\x00#\xcc"),
[]byte("\x00\x00\x00\x00\x00\x00#\xec"),
[]byte("c__main__\nObject\nq\x01.U\x05e1.13q\x02."),
0x0285cbad3a740e19,
},
......@@ -1804,7 +1804,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 11362,
Pos: 11394,
LenPrev: 215,
Len: 216,
TxnInfo: zodb.TxnInfo{
......@@ -1819,14 +1819,14 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 11520,
Pos: 11552,
Oid: 5,
Tid: 0x0285cbad7c28f64c,
PrevRevPos: 11067,
TxnPos: 11362,
PrevRevPos: 11099,
TxnPos: 11394,
DataLen: 0,
},
[]byte("\x00\x00\x00\x00\x00\x00*\x8e"),
[]byte("\x00\x00\x00\x00\x00\x00*\xae"),
[]byte("c__main__\nObject\nq\x01.U\x05a1.23q\x02."),
0x0285cbad6962fd19,
},
......@@ -1834,7 +1834,7 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 11578,
Pos: 11610,
LenPrev: 216,
Len: 370,
TxnInfo: zodb.TxnInfo{
......@@ -1849,11 +1849,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 11612,
Pos: 11644,
Oid: 0,
Tid: 0x0285cbad80da7499,
PrevRevPos: 6302,
TxnPos: 11578,
TxnPos: 11610,
DataLen: 216,
},
[]byte("cpersistent.mapping\nPersistentMapping\nq\x01.}q\x02U\x04dataq\x03}q\x04(U\x01a(U\x08\x00\x00\x00\x00\x00\x00\x00\x05q\x05c__main__\nObject\nq\x06tQU\x01c(U\x08\x00\x00\x00\x00\x00\x00\x00\x08q\x07h\x06tQU\x01b(U\x08\x00\x00\x00\x00\x00\x00\x00\x04q\x08h\x06tQU\x01e(U\x08\x00\x00\x00\x00\x00\x00\x00\tq\th\x06tQU\x01d(U\x08\x00\x00\x00\x00\x00\x00\x00\x02q\nh\x06tQU\x01g(U\x08\x00\x00\x00\x00\x00\x00\x00\x03q\x0bh\x06tQU\x01f(U\x08\x00\x00\x00\x00\x00\x00\x00\x01q\x0ch\x06tQus."),
......@@ -1862,11 +1862,11 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
DataHeader{
Pos: 11870,
Pos: 11902,
Oid: 9,
Tid: 0x0285cbad80da7499,
PrevRevPos: 0,
TxnPos: 11578,
TxnPos: 11610,
DataLen: 28,
},
[]byte("c__main__\nObject\nq\x01.U\x03e1*q\x02."),
......@@ -1877,13 +1877,13 @@ var _1fs_dbEntryv = [...]dbEntry{
},
{
TxnHeader{
Pos: 11948,
Pos: 11980,
LenPrev: 370,
Len: 214,
Len: 246,
TxnInfo: zodb.TxnInfo{
Tid: 0x0285cbad858bf2e6,
Status: ' ',
User: []byte("root1\nYour\nRoyal\nMagesty' "),
User: []byte("root1\nYour\nRoyal\nMagesty' \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"),
Description: []byte("delete 1\nalpha beta gamma'delta\"lambda\n\nqqq ..."),
Extension: []byte("}q\x01(U\tx-cookieSU\x05MC4OMU\x0bx-generatorq\x02U\x13zodb/py2 (delete 6)u."),
},
......@@ -1892,11 +1892,11 @@ var _1fs_dbEntryv = [...]dbEntry{
[]txnEntry{
{
DataHeader{
Pos: 12104,
Pos: 12168,
Oid: 6,
Tid: 0x0285cbad858bf2e6,
PrevRevPos: 11304,
TxnPos: 11948,
PrevRevPos: 11336,
TxnPos: 11980,
DataLen: 0,
},
[]byte("\x00\x00\x00\x00\x00\x00\x00\x00"),
......
......@@ -34,16 +34,23 @@ func loadZdumpPy(t *testing.T, path string) string {
t.Fatal(err)
}
// python qoutes "\v" as "\x0b", go as "\v"; same for "\f" vs "\x0c"
// python qoutes "\v" as "\x0b", go as "\v"; same for "\f", "\a", "\b".
// XXX this is a bit hacky. We could compare quoted strings as decoded,
// but this would need zdump format parser which could contain other
// bugs. Here we want to compare output ideally bit-to-bit but those
// \v vs \x0b glitches prevents that to be done directly. So here we
// are with this ugly hack:
r0b := regexp.MustCompile(`\\x0b`)
r0c := regexp.MustCompile(`\\x0c`)
dump = r0b.ReplaceAllLiteral(dump, []byte(`\v`))
dump = r0c.ReplaceAllLiteral(dump, []byte(`\f`))
var pyNoBackLetter = []struct {backNoLetterRe, backLetter string} {
{`\\x07`, `\a`},
{`\\x08`, `\b`},
{`\\x0b`, `\v`},
{`\\x0c`, `\f`},
}
for _, __ := range pyNoBackLetter {
re := regexp.MustCompile(__.backNoLetterRe)
dump = re.ReplaceAllLiteral(dump, []byte(__.backLetter))
}
return string(dump)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment