248
248
def test_gen_file_id(self):
249
self.assertStartsWith(bzrlib.workingtree.gen_file_id('bar'), 'bar-')
250
self.assertStartsWith(bzrlib.workingtree.gen_file_id('Mwoo oof\t m'), 'Mwoooofm-')
251
self.assertStartsWith(bzrlib.workingtree.gen_file_id('..gam.py'), 'gam.py-')
252
self.assertStartsWith(bzrlib.workingtree.gen_file_id('..Mwoo oof\t m'), 'Mwoooofm-')
249
gen_file_id = bzrlib.workingtree.gen_file_id
251
# We try to use the filename if possible
252
self.assertStartsWith(gen_file_id('bar'), 'bar-')
254
# but we squash capitalization, and remove non word characters
255
self.assertStartsWith(gen_file_id('Mwoo oof\t m'), 'mwoooofm-')
257
# We also remove leading '.' characters to prevent hidden file-ids
258
self.assertStartsWith(gen_file_id('..gam.py'), 'gam.py-')
259
self.assertStartsWith(gen_file_id('..Mwoo oof\t m'), 'mwoooofm-')
261
# we remove unicode characters, and still don't end up with a
263
self.assertStartsWith(gen_file_id(u'\xe5\xb5.txt'), 'txt-')
265
# We truncate long filenames to be friendly to OS. This is
266
# less important with case squashing, because we do less escaping
267
# (A long all-caps filename used to create a *huge* filename on disk)
268
fid = gen_file_id('A'*50 + '.txt')
269
self.assertStartsWith(fid, 'a'*20 + '-')
271
# restricting length happens after the other actions, so
272
# we preserv as much as possible
273
fid = gen_file_id('\xe5\xb5..aBcd\tefGhijKLMnop\tqrstuvwxyz')
274
self.assertStartsWith(fid, 'abcdefghijklmnopqrst-')
254
276
def test_next_id_suffix(self):
255
277
bzrlib.workingtree._gen_id_suffix = None