/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/cache_utf8.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
"""Some functions to enable caching the conversion between unicode to utf8"""
21
21
 
22
 
from __future__ import absolute_import
23
 
 
24
22
import codecs
25
23
 
 
24
 
26
25
_utf8_encode = codecs.utf_8_encode
27
26
_utf8_decode = codecs.utf_8_decode
28
 
 
29
 
 
30
27
def _utf8_decode_with_None(bytestring, _utf8_decode=_utf8_decode):
31
28
    """wrap _utf8_decode to support None->None for optional strings.
32
29
 
38
35
    else:
39
36
        return _utf8_decode(bytestring)[0]
40
37
 
41
 
 
42
38
# Map revisions from and to utf8 encoding
43
39
# Whenever we do an encode/decode operation, we save the result, so that
44
40
# we don't have to do it again.
111
107
    # real Unicode string. Unicode and plain strings of this type will have the
112
108
    # same hash, so we can just use it as the key in _uni_to_utf8, but we need
113
109
    # the return value to be different in _utf8_to_uni
114
 
    uni_str = ascii_str.decode('ascii')
115
 
    ascii_str = _uni_to_utf8.setdefault(uni_str, ascii_str)
116
 
    _utf8_to_uni.setdefault(ascii_str, uni_str)
 
110
    ascii_str = _uni_to_utf8.setdefault(ascii_str, ascii_str)
 
111
    _utf8_to_uni.setdefault(ascii_str, unicode(ascii_str))
117
112
    return ascii_str
118
113
 
119
114