/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: John Arbash Meinel
  • Date: 2011-04-22 14:12:22 UTC
  • mfrom: (5809 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5836.
  • Revision ID: john@arbash-meinel.com-20110422141222-nx2j0hbkihcb8j16
Merge newer bzr.dev and resolve conflicts.
Try to write some documentation about how the _dirblock_state works.
Fix up the tests so that they pass again.

Show diffs side-by-side

added added

removed removed

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