Mercurial > public > mercurial-scm > hg
comparison mercurial/obsolete.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 | 413b44003462 |
children | 7c3ef55dedbe |
comparison
equal
deleted
inserted
replaced
32200:2d84947cd85d | 32201:4462a981e8df |
---|---|
72 import errno | 72 import errno |
73 import struct | 73 import struct |
74 | 74 |
75 from .i18n import _ | 75 from .i18n import _ |
76 from . import ( | 76 from . import ( |
77 base85, | |
78 error, | 77 error, |
79 node, | 78 node, |
80 parsers, | 79 parsers, |
81 phases, | 80 phases, |
82 util, | 81 util, |
742 parts.append(currentpart) | 741 parts.append(currentpart) |
743 currentpart.append(nextdata) | 742 currentpart.append(nextdata) |
744 currentlen += len(nextdata) | 743 currentlen += len(nextdata) |
745 for idx, part in enumerate(reversed(parts)): | 744 for idx, part in enumerate(reversed(parts)): |
746 data = ''.join([_pack('>B', _fm0version)] + part) | 745 data = ''.join([_pack('>B', _fm0version)] + part) |
747 keys['dump%i' % idx] = base85.b85encode(data) | 746 keys['dump%i' % idx] = util.b85encode(data) |
748 return keys | 747 return keys |
749 | 748 |
750 def listmarkers(repo): | 749 def listmarkers(repo): |
751 """List markers over pushkey""" | 750 """List markers over pushkey""" |
752 if not repo.obsstore: | 751 if not repo.obsstore: |
759 repo.ui.warn(_('unknown key: %r') % key) | 758 repo.ui.warn(_('unknown key: %r') % key) |
760 return 0 | 759 return 0 |
761 if old: | 760 if old: |
762 repo.ui.warn(_('unexpected old value for %r') % key) | 761 repo.ui.warn(_('unexpected old value for %r') % key) |
763 return 0 | 762 return 0 |
764 data = base85.b85decode(new) | 763 data = util.b85decode(new) |
765 lock = repo.lock() | 764 lock = repo.lock() |
766 try: | 765 try: |
767 tr = repo.transaction('pushkey: obsolete markers') | 766 tr = repo.transaction('pushkey: obsolete markers') |
768 try: | 767 try: |
769 repo.obsstore.mergemarkers(tr, data) | 768 repo.obsstore.mergemarkers(tr, data) |