/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/tests/test_escaped_store.py

  • Committer: Robert Collins
  • Date: 2007-03-08 04:06:06 UTC
  • mfrom: (2323.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2442.
  • Revision ID: robertc@robertcollins.net-20070308040606-84gsniv56huiyjt4
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Development Ltd
2
 
 
 
1
# Copyright (C) 2005, 2007 Canonical Ltd
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
20
import os
21
21
import gzip
22
22
 
 
23
from bzrlib import osutils
23
24
from bzrlib.errors import BzrError, UnlistableStore, NoSuchFile
24
25
from bzrlib.store import copy_all
25
26
from bzrlib.store.text import TextStore
50
51
        # hash_prefix() is not defined for unicode characters
51
52
        # it is only defined for byte streams.
52
53
        # so hash_prefix() needs to operate on *at most* utf-8
53
 
        # encoded. However urlescape() does both encoding to utf-8
 
54
        # encoded. However urlutils.escape() does both encoding to utf-8
54
55
        # and urllib quoting, so we will use the escaped form
55
56
        # as the path passed to hash_prefix
56
57
 
74
75
        self.failUnlessExists('72/@%3a%3c%3e')
75
76
        self.assertEquals('surprise', text_store.get('@:<>').read())
76
77
 
77
 
        text_store.add(StringIO('unicode'), u'\xe5')
 
78
        self.callDeprecated([osutils._file_id_warning],
 
79
                            text_store.add, StringIO('unicode'), u'\xe5')
78
80
        self.failUnlessExists('77/%c3%a5')
79
 
        self.assertEquals('unicode', text_store.get(u'\xe5').read())
 
81
        self.assertEquals('unicode',
 
82
                          self.callDeprecated([osutils._file_id_warning],
 
83
                          text_store.get, u'\xe5').read())
 
84
        self.assertEquals('unicode', text_store.get('\xc3\xa5').read())
 
85
 
 
86
        text_store.add(StringIO('utf8'), '\xc2\xb5')
 
87
        self.failUnlessExists('77/%c2%b5')
 
88
        self.assertEquals('utf8', text_store.get('\xc2\xb5').read())
 
89
        self.assertEquals('utf8',
 
90
                          self.callDeprecated([osutils._file_id_warning],
 
91
                          text_store.get, u'\xb5').read())
80
92
 
81
93
    def test_weave(self):
82
94
        from bzrlib.store.versioned import WeaveStore
107
119
        self.failUnlessExists('72/@%3a%3c%3e.weave')
108
120
        check_text('@:<>', 'r', ['surprise'])
109
121
 
110
 
        add_text(u'\xe5', 'r', ['unicode'], [], trans)
 
122
        self.callDeprecated([osutils._file_id_warning],
 
123
                            add_text, u'\xe5', 'r', ['unicode'], [], trans)
111
124
        self.failUnlessExists('77/%c3%a5.weave')
112
 
        check_text(u'\xe5', 'r', ['unicode'])
 
125
        self.callDeprecated([osutils._file_id_warning],
 
126
                            check_text, u'\xe5', 'r', ['unicode'])
 
127
        check_text('\xc3\xa5', 'r', ['unicode'])
 
128
 
 
129
        add_text('\xc2\xb5', 'r', ['utf8'], [], trans)
 
130
        self.failUnlessExists('77/%c2%b5.weave')
 
131
        check_text('\xc2\xb5', 'r', ['utf8'])
 
132
        self.callDeprecated([osutils._file_id_warning],
 
133
                            check_text, u'\xb5', 'r', ['utf8'])