322
322
raise NotImplementedError(self.get_symlink_target)
324
def get_canonical_path(self, path):
325
"""Returns the first entry that case-insensitively matches the input.
327
If the path matches exactly, it is returned. If no path matches exactly
328
but more than one path matches case-insensitively, it is implementation
329
defined which is returned.
331
If no path matches case-insensitively, the input path is returned, but
332
with as many entries that do exist changed to their canonical form.
334
:param path: A path, relative to the root of the tree.
335
:return: The input path adjusted to account for existing elements that
336
match case insensitively.
338
# First, if the path as specified exists exactly, just use it.
339
if self.path2id(path) is not None:
342
cur_id = self.get_root_id()
344
bit_iter = iter(path.split("/"))
347
for child in self.iter_children(cur_id):
348
child_base = os.path.basename(self.id2path(child))
349
if child_base.lower() == lelt:
351
cur_path = osutils.pathjoin(cur_path, child_base)
354
# got to the end of this directory and no entries matched.
355
# Return what matched so far, plus the rest as specified.
356
cur_path = osutils.pathjoin(cur_path, elt, *list(bit_iter))
324
360
def get_root_id(self):
325
361
"""Return the file_id for the root of this tree."""
326
362
raise NotImplementedError(self.get_root_id)