comparison mercurial/patch.py @ 32245:4462a981e8df

base85: proxy through util module I'm going to replace hgimporter with a simpler import function, so we can access to pure/cext modules by name: # util.py base85 = policy.importmod('base85') # select pure.base85 or cext.base85 # cffi/base85.py from ..pure.base85 import * # may re-export pure.base85 functions This means we'll have to use policy.importmod() function in place of the standard import statement, but we wouldn't want to write it every place where C extension modules are used. So this patch makes util host base85 functions.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 26 Apr 2017 21:56:47 +0900
parents 31f42e683321
children 0e29ce16ec38
comparison
equal deleted inserted replaced
32244:2d84947cd85d 32245:4462a981e8df
24 from .node import ( 24 from .node import (
25 hex, 25 hex,
26 short, 26 short,
27 ) 27 )
28 from . import ( 28 from . import (
29 base85,
30 copies, 29 copies,
31 diffhelpers, 30 diffhelpers,
32 encoding, 31 encoding,
33 error, 32 error,
34 mail, 33 mail,
1428 if l <= 'Z' and l >= 'A': 1427 if l <= 'Z' and l >= 'A':
1429 l = ord(l) - ord('A') + 1 1428 l = ord(l) - ord('A') + 1
1430 else: 1429 else:
1431 l = ord(l) - ord('a') + 27 1430 l = ord(l) - ord('a') + 27
1432 try: 1431 try:
1433 dec.append(base85.b85decode(line[1:])[:l]) 1432 dec.append(util.b85decode(line[1:])[:l])
1434 except ValueError as e: 1433 except ValueError as e:
1435 raise PatchError(_('could not decode "%s" binary patch: %s') 1434 raise PatchError(_('could not decode "%s" binary patch: %s')
1436 % (self._fname, str(e))) 1435 % (self._fname, str(e)))
1437 line = getline(lr, self.hunk) 1436 line = getline(lr, self.hunk)
1438 text = zlib.decompress(''.join(dec)) 1437 text = zlib.decompress(''.join(dec))