/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_workingtree.py

  • Committer: Aaron Bentley
  • Date: 2006-11-17 04:06:03 UTC
  • mfrom: (2139 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2162.
  • Revision ID: aaron.bentley@utoronto.ca-20061117040603-pgebxndswvwk26tt
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.lockdir import LockDir
28
28
from bzrlib.mutabletree import needs_tree_write_lock
29
29
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
 
30
from bzrlib.symbol_versioning import zero_thirteen
30
31
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
31
32
from bzrlib.trace import mutter
32
33
from bzrlib.transport import get_transport
173
174
        t = control.get_workingtree_transport(None)
174
175
        self.assertEqualDiff('Bazaar-NG Working Tree format 3',
175
176
                             t.get('format').read())
176
 
        self.assertEqualDiff('<inventory format="5">\n'
177
 
                             '</inventory>\n',
178
 
                             t.get('inventory').read())
 
177
        # self.assertContainsRe(t.get('inventory').read(), 
 
178
        #                       '<inventory file_id="[^"]*" format="5">\n'
 
179
        #                       '</inventory>\n',
 
180
        #                      )
 
181
        # WorkingTreeFormat3 doesn't default to creating a unique root id,
 
182
        # because it is incompatible with older bzr versions
 
183
        self.assertContainsRe(t.get('inventory').read(),
 
184
                              '<inventory format="5">\n'
 
185
                              '</inventory>\n',
 
186
                             )
179
187
        self.assertEqualDiff('### bzr hashcache v5\n',
180
188
                             t.get('stat-cache').read())
181
189
        self.assertFalse(t.has('inventory.basis'))
251
259
class TestNonFormatSpecificCode(TestCaseWithTransport):
252
260
    """This class contains tests of workingtree that are not format specific."""
253
261
 
254
 
    
255
262
    def test_gen_file_id(self):
256
 
        gen_file_id = bzrlib.workingtree.gen_file_id
257
 
 
258
 
        # We try to use the filename if possible
259
 
        self.assertStartsWith(gen_file_id('bar'), 'bar-')
260
 
 
261
 
        # but we squash capitalization, and remove non word characters
262
 
        self.assertStartsWith(gen_file_id('Mwoo oof\t m'), 'mwoooofm-')
263
 
 
264
 
        # We also remove leading '.' characters to prevent hidden file-ids
265
 
        self.assertStartsWith(gen_file_id('..gam.py'), 'gam.py-')
266
 
        self.assertStartsWith(gen_file_id('..Mwoo oof\t m'), 'mwoooofm-')
267
 
 
268
 
        # we remove unicode characters, and still don't end up with a 
269
 
        # hidden file id
270
 
        self.assertStartsWith(gen_file_id(u'\xe5\xb5.txt'), 'txt-')
 
263
        file_id = self.applyDeprecated(zero_thirteen, workingtree.gen_file_id,
 
264
                                      'filename')
 
265
        self.assertStartsWith(file_id, 'filename-')
 
266
 
 
267
    def test_gen_root_id(self):
 
268
        file_id = self.applyDeprecated(zero_thirteen, workingtree.gen_root_id)
 
269
        self.assertStartsWith(file_id, 'tree_root-')
271
270
        
272
 
        # Our current method of generating unique ids adds 33 characters
273
 
        # plus an serial number (log10(N) characters)
274
 
        # to the end of the filename. We now restrict the filename portion to
275
 
        # be <= 20 characters, so the maximum length should now be approx < 60
276
 
 
277
 
        # Test both case squashing and length restriction
278
 
        fid = gen_file_id('A'*50 + '.txt')
279
 
        self.assertStartsWith(fid, 'a'*20 + '-')
280
 
        self.failUnless(len(fid) < 60)
281
 
 
282
 
        # restricting length happens after the other actions, so
283
 
        # we preserve as much as possible
284
 
        fid = gen_file_id('\xe5\xb5..aBcd\tefGhijKLMnop\tqrstuvwxyz')
285
 
        self.assertStartsWith(fid, 'abcdefghijklmnopqrst-')
286
 
        self.failUnless(len(fid) < 60)
287
 
 
288
 
    def test_next_id_suffix(self):
289
 
        bzrlib.workingtree._gen_id_suffix = None
290
 
        bzrlib.workingtree._next_id_suffix()
291
 
        self.assertNotEqual(None, bzrlib.workingtree._gen_id_suffix)
292
 
        bzrlib.workingtree._gen_id_suffix = "foo-"
293
 
        bzrlib.workingtree._gen_id_serial = 1
294
 
        self.assertEqual("foo-2", bzrlib.workingtree._next_id_suffix())
295
 
        self.assertEqual("foo-3", bzrlib.workingtree._next_id_suffix())
296
 
        self.assertEqual("foo-4", bzrlib.workingtree._next_id_suffix())
297
 
        self.assertEqual("foo-5", bzrlib.workingtree._next_id_suffix())
298
 
        self.assertEqual("foo-6", bzrlib.workingtree._next_id_suffix())
299
 
        self.assertEqual("foo-7", bzrlib.workingtree._next_id_suffix())
300
 
        self.assertEqual("foo-8", bzrlib.workingtree._next_id_suffix())
301
 
        self.assertEqual("foo-9", bzrlib.workingtree._next_id_suffix())
302
 
        self.assertEqual("foo-10", bzrlib.workingtree._next_id_suffix())
303
 
 
304
271
    def test__translate_ignore_rule(self):
305
272
        tree = self.make_branch_and_tree('.')
306
273
        # translation should return the regex, the number of groups in it,