/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: Canonical.com Patch Queue Manager
  • Date: 2006-07-20 19:30:54 UTC
  • mfrom: (1864.4.2 smaller-file-ids)
  • Revision ID: pqm@pqm.ubuntu.com-20060720193054-cff67111d7eca9b9
(jam) squash file ids to make them friendlier to limited filesystems (bug #43801)

Show diffs side-by-side

added added

removed removed

Lines of Context:
247
247
 
248
248
    
249
249
    def test_gen_file_id(self):
250
 
        self.assertStartsWith(bzrlib.workingtree.gen_file_id('bar'), 'bar-')
251
 
        self.assertStartsWith(bzrlib.workingtree.gen_file_id('Mwoo oof\t m'), 'Mwoooofm-')
252
 
        self.assertStartsWith(bzrlib.workingtree.gen_file_id('..gam.py'), 'gam.py-')
253
 
        self.assertStartsWith(bzrlib.workingtree.gen_file_id('..Mwoo oof\t m'), 'Mwoooofm-')
 
250
        gen_file_id = bzrlib.workingtree.gen_file_id
 
251
 
 
252
        # We try to use the filename if possible
 
253
        self.assertStartsWith(gen_file_id('bar'), 'bar-')
 
254
 
 
255
        # but we squash capitalization, and remove non word characters
 
256
        self.assertStartsWith(gen_file_id('Mwoo oof\t m'), 'mwoooofm-')
 
257
 
 
258
        # We also remove leading '.' characters to prevent hidden file-ids
 
259
        self.assertStartsWith(gen_file_id('..gam.py'), 'gam.py-')
 
260
        self.assertStartsWith(gen_file_id('..Mwoo oof\t m'), 'mwoooofm-')
 
261
 
 
262
        # we remove unicode characters, and still don't end up with a 
 
263
        # hidden file id
 
264
        self.assertStartsWith(gen_file_id(u'\xe5\xb5.txt'), 'txt-')
 
265
        
 
266
        # Our current method of generating unique ids adds 33 characters
 
267
        # plus an serial number (log10(N) characters)
 
268
        # to the end of the filename. We now restrict the filename portion to
 
269
        # be <= 20 characters, so the maximum length should now be approx < 60
 
270
 
 
271
        # Test both case squashing and length restriction
 
272
        fid = gen_file_id('A'*50 + '.txt')
 
273
        self.assertStartsWith(fid, 'a'*20 + '-')
 
274
        self.failUnless(len(fid) < 60)
 
275
 
 
276
        # restricting length happens after the other actions, so
 
277
        # we preserve as much as possible
 
278
        fid = gen_file_id('\xe5\xb5..aBcd\tefGhijKLMnop\tqrstuvwxyz')
 
279
        self.assertStartsWith(fid, 'abcdefghijklmnopqrst-')
 
280
        self.failUnless(len(fid) < 60)
254
281
 
255
282
    def test_next_id_suffix(self):
256
283
        bzrlib.workingtree._gen_id_suffix = None