/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/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:
107
107
import bzrlib.xml5
108
108
 
109
109
 
110
 
# the regex here does the following:
111
 
# 1) remove any weird characters; we don't escape them but rather
112
 
# just pull them out
113
 
 # 2) match leading '.'s to make it not hidden
114
 
_gen_file_id_re = re.compile(r'[^\w.]|(^\.*)')
 
110
# the regex removes any weird characters; we don't escape them 
 
111
# but rather just pull them out
 
112
_gen_file_id_re = re.compile(r'[^\w.]')
115
113
_gen_id_suffix = None
116
114
_gen_id_serial = 0
117
115
 
139
137
 
140
138
    The uniqueness is supplied from _next_id_suffix.
141
139
    """
142
 
    # XXX TODO: squash the filename to lowercase.
143
 
    # XXX TODO: truncate the filename to something like 20 or 30 chars.
144
 
    # XXX TODO: consider what to do with ids that look like illegal filepaths
145
 
    # on platforms we support.
146
 
    return _gen_file_id_re.sub('', name) + _next_id_suffix()
 
140
    # The real randomness is in the _next_id_suffix, the
 
141
    # rest of the identifier is just to be nice.
 
142
    # So we:
 
143
    # 1) Remove non-ascii word characters to keep the ids portable
 
144
    # 2) squash to lowercase, so the file id doesn't have to
 
145
    #    be escaped (case insensitive filesystems would bork for ids
 
146
    #    that only differred in case without escaping).
 
147
    # 3) truncate the filename to 20 chars. Long filenames also bork on some
 
148
    #    filesystems
 
149
    # 4) Removing starting '.' characters to prevent the file ids from
 
150
    #    being considered hidden.
 
151
    ascii_word_only = _gen_file_id_re.sub('', name.lower())
 
152
    short_no_dots = ascii_word_only.lstrip('.')[:20]
 
153
    return short_no_dots + _next_id_suffix()
147
154
 
148
155
 
149
156
def gen_root_id():