~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Martin Pool
  • Date: 2010-02-11 08:47:14 UTC
  • mto: (4634.132.1 2.0)
  • mto: This revision was merged to the branch mainline in revision 5033.
  • Revision ID: mbp@sourcefrog.net-20100211084714-adamqj47rrh96txd
_yield_canonical_inventory_paths copes better with case sensitivity.

If there is an exact case match that should be prefered to an approximate match.

Based on a patch by Chris Jones.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2009 Canonical Ltd
 
1
# Copyright (C) 2005, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
404
404
            bit_iter = iter(path.split("/"))
405
405
            for elt in bit_iter:
406
406
                lelt = elt.lower()
 
407
                new_path = None
407
408
                for child in self.iter_children(cur_id):
408
409
                    try:
 
410
                        # XXX: it seem like if the child is known to be in the
 
411
                        # tree, we shouldn't need to go from its id back to
 
412
                        # its path -- mbp 2010-02-11
 
413
                        #
 
414
                        # XXX: it seems like we could be more efficient
 
415
                        # by just directly looking up the original name and
 
416
                        # only then searching all children; also by not
 
417
                        # chopping paths so much. -- mbp 2010-02-11
409
418
                        child_base = os.path.basename(self.id2path(child))
410
 
                        if child_base.lower() == lelt:
 
419
                        if (child_base == elt):
 
420
                            # if we found an exact match, we can stop now; if
 
421
                            # we found an approximate match we need to keep
 
422
                            # searching because there might be an exact match
 
423
                            # later.  
411
424
                            cur_id = child
412
 
                            cur_path = osutils.pathjoin(cur_path, child_base)
 
425
                            new_path = osutils.pathjoin(cur_path, child_base)
413
426
                            break
 
427
                        elif child_base.lower() == lelt:
 
428
                            cur_id = child
 
429
                            new_path = osutils.pathjoin(cur_path, child_base)
414
430
                    except NoSuchId:
415
431
                        # before a change is committed we can see this error...
416
432
                        continue
 
433
                if new_path:
 
434
                    cur_path = new_path
417
435
                else:
418
436
                    # got to the end of this directory and no entries matched.
419
437
                    # Return what matched so far, plus the rest as specified.