~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-13 05:14:24 UTC
  • mfrom: (3936.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090113051424-nrk3zkfe09h46i9y
(mbp) merge 1.11 and advance to 1.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    A mutable tree always has an associated Branch and BzrDir object - the
76
76
    branch and bzrdir attributes.
77
77
    """
 
78
    def __init__(self, *args, **kw):
 
79
        super(MutableTree, self).__init__(*args, **kw)
 
80
        # Is this tree on a case-insensitive or case-preserving file-system?
 
81
        # Sub-classes may initialize to False if they detect they are being
 
82
        # used on media which doesn't differentiate the case of names.
 
83
        self.case_sensitive = True
78
84
 
79
85
    @needs_tree_write_lock
80
86
    def add(self, files, ids=None, kinds=None):
283
289
        :return: None
284
290
        """
285
291
 
 
292
    def _fix_case_of_inventory_path(self, path):
 
293
        """If our tree isn't case sensitive, return the canonical path"""
 
294
        if not self.case_sensitive:
 
295
            path = self.get_canonical_inventory_path(path)
 
296
        return path
 
297
 
286
298
    @needs_write_lock
287
299
    def put_file_bytes_non_atomic(self, file_id, bytes):
288
300
        """Update the content of a file in the tree.
347
359
 
348
360
        # validate user file paths and convert all paths to tree 
349
361
        # relative : it's cheaper to make a tree relative path an abspath
350
 
        # than to convert an abspath to tree relative.
351
 
        for filepath in file_list:
352
 
            rf = _FastPath(self.relpath(filepath))
 
362
        # than to convert an abspath to tree relative, and it's cheaper to
 
363
        # perform the canonicalization in bulk.
 
364
        for filepath in osutils.canonical_relpaths(self.basedir, file_list):
 
365
            rf = _FastPath(filepath)
353
366
            # validate user parameters. Our recursive code avoids adding new files
354
367
            # that need such validation 
355
368
            if self.is_control_filename(rf.raw_path):
410
423
            else:
411
424
                # without the parent ie, use the relatively slower inventory 
412
425
                # probing method
413
 
                versioned = inv.has_filename(directory.raw_path)
 
426
                versioned = inv.has_filename(
 
427
                        self._fix_case_of_inventory_path(directory.raw_path))
414
428
 
415
429
            if kind == 'directory':
416
430
                try:
449
463
                else:
450
464
                    # without the parent ie, use the relatively slower inventory 
451
465
                    # probing method
452
 
                    this_id = inv.path2id(directory.raw_path)
 
466
                    this_id = inv.path2id(
 
467
                            self._fix_case_of_inventory_path(directory.raw_path))
453
468
                    if this_id is None:
454
469
                        this_ie = None
455
470
                    else:
581
596
        added = []
582
597
    else:
583
598
        # slower but does not need parent_ie
584
 
        if inv.has_filename(path.raw_path):
 
599
        if inv.has_filename(tree._fix_case_of_inventory_path(path.raw_path)):
585
600
            return []
586
601
        # its really not there : add the parent
587
602
        # note that the dirname use leads to some extra str copying etc but as