Mercurial > public > mercurial-scm > hg
comparison mercurial/mdiff.py @ 32201: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 | 2d84947cd85d |
children | ded48ad55146 |
comparison
equal
deleted
inserted
replaced
32200:2d84947cd85d | 32201:4462a981e8df |
---|---|
11 import struct | 11 import struct |
12 import zlib | 12 import zlib |
13 | 13 |
14 from .i18n import _ | 14 from .i18n import _ |
15 from . import ( | 15 from . import ( |
16 base85, | |
17 bdiff, | 16 bdiff, |
18 error, | 17 error, |
19 mpatch, | 18 mpatch, |
20 pycompat, | 19 pycompat, |
21 util, | 20 util, |
428 l = len(line) | 427 l = len(line) |
429 if l <= 26: | 428 if l <= 26: |
430 l = chr(ord('A') + l - 1) | 429 l = chr(ord('A') + l - 1) |
431 else: | 430 else: |
432 l = chr(l - 26 + ord('a') - 1) | 431 l = chr(l - 26 + ord('a') - 1) |
433 return '%c%s\n' % (l, base85.b85encode(line, True)) | 432 return '%c%s\n' % (l, util.b85encode(line, True)) |
434 | 433 |
435 def chunk(text, csize=52): | 434 def chunk(text, csize=52): |
436 l = len(text) | 435 l = len(text) |
437 i = 0 | 436 i = 0 |
438 while i < l: | 437 while i < l: |