Mercurial > hg
comparison tests/test-linelog.py @ 38809:57af5ee15b35
linelog: port to Python 3
Differential Revision: https://phab.mercurial-scm.org/D4051
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 01 Aug 2018 23:25:35 -0400 |
parents | 422d661056be |
children | 6fed8b323651 |
comparison
equal
deleted
inserted
replaced
38808:d99083996398 | 38809:57af5ee15b35 |
---|---|
39 # round-trips okay | 39 # round-trips okay |
40 self.assertEqual(linelog.linelog.fromdata(enc)._program, ll._program) | 40 self.assertEqual(linelog.linelog.fromdata(enc)._program, ll._program) |
41 self.assertEqual(linelog.linelog.fromdata(enc), ll) | 41 self.assertEqual(linelog.linelog.fromdata(enc), ll) |
42 # This encoding matches the encoding used by hg-experimental's | 42 # This encoding matches the encoding used by hg-experimental's |
43 # linelog file, or is supposed to if it doesn't. | 43 # linelog file, or is supposed to if it doesn't. |
44 self.assertEqual(enc, ('\x00\x00\x01\x90\x00\x00\x00\x06' | 44 self.assertEqual(enc, (b'\x00\x00\x01\x90\x00\x00\x00\x06' |
45 '\x00\x00\x00\xa4\x00\x00\x00*' | 45 b'\x00\x00\x00\xa4\x00\x00\x00*' |
46 '\x00\x00\x00\x00\x00\x00\x00+' | 46 b'\x00\x00\x00\x00\x00\x00\x00+' |
47 '\x00\x00\x00\x00\x00\x00\x00\x00' | 47 b'\x00\x00\x00\x00\x00\x00\x00\x00' |
48 '\x00\x00\x00\xb1\x00\x00\x00-' | 48 b'\x00\x00\x00\xb1\x00\x00\x00-' |
49 '\x00\x00\x00\xba\x00\x00\x00/')) | 49 b'\x00\x00\x00\xba\x00\x00\x00/')) |
50 | 50 |
51 def testsimpleedits(self): | 51 def testsimpleedits(self): |
52 ll = linelog.linelog() | 52 ll = linelog.linelog() |
53 # Initial revision: add lines 0, 1, and 2 | 53 # Initial revision: add lines 0, 1, and 2 |
54 ll.replacelines(1, 0, 0, 0, 3) | 54 ll.replacelines(1, 0, 0, 0, 3) |
92 ]) | 92 ]) |
93 | 93 |
94 def testparseclinelogfile(self): | 94 def testparseclinelogfile(self): |
95 # This data is what the replacements in testsimpleedits | 95 # This data is what the replacements in testsimpleedits |
96 # produce when fed to the original linelog.c implementation. | 96 # produce when fed to the original linelog.c implementation. |
97 data = ('\x00\x00\x00\x0c\x00\x00\x00\x0f' | 97 data = (b'\x00\x00\x00\x0c\x00\x00\x00\x0f' |
98 '\x00\x00\x00\x00\x00\x00\x00\x02' | 98 b'\x00\x00\x00\x00\x00\x00\x00\x02' |
99 '\x00\x00\x00\x05\x00\x00\x00\x06' | 99 b'\x00\x00\x00\x05\x00\x00\x00\x06' |
100 '\x00\x00\x00\x06\x00\x00\x00\x00' | 100 b'\x00\x00\x00\x06\x00\x00\x00\x00' |
101 '\x00\x00\x00\x00\x00\x00\x00\x07' | 101 b'\x00\x00\x00\x00\x00\x00\x00\x07' |
102 '\x00\x00\x00\x06\x00\x00\x00\x02' | 102 b'\x00\x00\x00\x06\x00\x00\x00\x02' |
103 '\x00\x00\x00\x00\x00\x00\x00\x00' | 103 b'\x00\x00\x00\x00\x00\x00\x00\x00' |
104 '\x00\x00\x00\t\x00\x00\x00\t' | 104 b'\x00\x00\x00\t\x00\x00\x00\t' |
105 '\x00\x00\x00\x00\x00\x00\x00\x0c' | 105 b'\x00\x00\x00\x00\x00\x00\x00\x0c' |
106 '\x00\x00\x00\x08\x00\x00\x00\x05' | 106 b'\x00\x00\x00\x08\x00\x00\x00\x05' |
107 '\x00\x00\x00\x06\x00\x00\x00\x01' | 107 b'\x00\x00\x00\x06\x00\x00\x00\x01' |
108 '\x00\x00\x00\x00\x00\x00\x00\x05' | 108 b'\x00\x00\x00\x00\x00\x00\x00\x05' |
109 '\x00\x00\x00\x0c\x00\x00\x00\x05' | 109 b'\x00\x00\x00\x0c\x00\x00\x00\x05' |
110 '\x00\x00\x00\n\x00\x00\x00\x01' | 110 b'\x00\x00\x00\n\x00\x00\x00\x01' |
111 '\x00\x00\x00\x00\x00\x00\x00\t') | 111 b'\x00\x00\x00\x00\x00\x00\x00\t') |
112 llc = linelog.linelog.fromdata(data) | 112 llc = linelog.linelog.fromdata(data) |
113 self.assertEqual([(l.rev, l.linenum) for l in llc.annotate(1)], | 113 self.assertEqual([(l.rev, l.linenum) for l in llc.annotate(1)], |
114 [(1, 0), | 114 [(1, 0), |
115 (1, 1), | 115 (1, 1), |
116 (1, 2), | 116 (1, 2), |