##// END OF EJS Templates
linelog: port to Python 3...
Augie Fackler -
r38845:57af5ee1 default
parent child Browse files
Show More
@@ -254,6 +254,7 b' test-largefiles-update.t'
254 test-largefiles.t
254 test-largefiles.t
255 test-lfs-largefiles.t
255 test-lfs-largefiles.t
256 test-lfs-pointer.py
256 test-lfs-pointer.py
257 test-linelog.py
257 test-linerange.py
258 test-linerange.py
258 test-locate.t
259 test-locate.t
259 test-lock-badness.t
260 test-lock-badness.t
@@ -98,7 +98,7 b' class _jge(_llinstruction):'
98 self._target = op2
98 self._target = op2
99
99
100 def __str__(self):
100 def __str__(self):
101 return 'JGE %d %d' % (self._cmprev, self._target)
101 return r'JGE %d %d' % (self._cmprev, self._target)
102
102
103 def __eq__(self, other):
103 def __eq__(self, other):
104 return (type(self) == type(other)
104 return (type(self) == type(other)
@@ -122,7 +122,7 b' class _jump(_llinstruction):'
122 self._target = op2
122 self._target = op2
123
123
124 def __str__(self):
124 def __str__(self):
125 return 'JUMP %d' % (self._target)
125 return r'JUMP %d' % (self._target)
126
126
127 def __eq__(self, other):
127 def __eq__(self, other):
128 return (type(self) == type(other)
128 return (type(self) == type(other)
@@ -144,7 +144,7 b' class _eof(_llinstruction):'
144 raise LineLogError("malformed EOF, op2 must be 0, got %d" % op2)
144 raise LineLogError("malformed EOF, op2 must be 0, got %d" % op2)
145
145
146 def __str__(self):
146 def __str__(self):
147 return 'EOF'
147 return r'EOF'
148
148
149 def __eq__(self, other):
149 def __eq__(self, other):
150 return type(self) == type(other)
150 return type(self) == type(other)
@@ -163,7 +163,7 b' class _jl(_llinstruction):'
163 self._target = op2
163 self._target = op2
164
164
165 def __str__(self):
165 def __str__(self):
166 return 'JL %d %d' % (self._cmprev, self._target)
166 return r'JL %d %d' % (self._cmprev, self._target)
167
167
168 def __eq__(self, other):
168 def __eq__(self, other):
169 return (type(self) == type(other)
169 return (type(self) == type(other)
@@ -188,7 +188,7 b' class _line(_llinstruction):'
188 self._origlineno = op2
188 self._origlineno = op2
189
189
190 def __str__(self):
190 def __str__(self):
191 return 'LINE %d %d' % (self._rev, self._origlineno)
191 return r'LINE %d %d' % (self._rev, self._origlineno)
192
192
193 def __eq__(self, other):
193 def __eq__(self, other):
194 return (type(self) == type(other)
194 return (type(self) == type(other)
@@ -245,8 +245,8 b' class linelog(object):'
245 hex(id(self)), self._maxrev, len(self._program))
245 hex(id(self)), self._maxrev, len(self._program))
246
246
247 def debugstr(self):
247 def debugstr(self):
248 fmt = '%%%dd %%s' % len(str(len(self._program)))
248 fmt = r'%%%dd %%s' % len(str(len(self._program)))
249 return '\n'.join(
249 return pycompat.sysstr('\n').join(
250 fmt % (idx, i) for idx, i in enumerate(self._program[1:], 1))
250 fmt % (idx, i) for idx, i in enumerate(self._program[1:], 1))
251
251
252 @classmethod
252 @classmethod
@@ -41,12 +41,12 b' class linelogtests(unittest.TestCase):'
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()
@@ -94,21 +94,21 b' class linelogtests(unittest.TestCase):'
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),
General Comments 0
You need to be logged in to leave comments. Login now