/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: Martin Pool
  • Date: 2008-05-08 04:33:38 UTC
  • mfrom: (3414 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080508043338-ru3vflx8z641a76k
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
        deprecated_method,
112
112
        deprecated_function,
113
113
        DEPRECATED_PARAMETER,
114
 
        zero_eight,
115
 
        zero_eleven,
116
 
        zero_thirteen,
117
114
        )
118
115
 
119
116
 
123
120
ERROR_PATH_NOT_FOUND = 3    # WindowsError errno code, equivalent to ENOENT
124
121
 
125
122
 
126
 
@deprecated_function(zero_thirteen)
127
 
def gen_file_id(name):
128
 
    """Return new file id for the basename 'name'.
129
 
 
130
 
    Use bzrlib.generate_ids.gen_file_id() instead
131
 
    """
132
 
    return generate_ids.gen_file_id(name)
133
 
 
134
 
 
135
 
@deprecated_function(zero_thirteen)
136
 
def gen_root_id():
137
 
    """Return a new tree-root file id.
138
 
 
139
 
    This has been deprecated in favor of bzrlib.generate_ids.gen_root_id()
140
 
    """
141
 
    return generate_ids.gen_root_id()
142
 
 
143
 
 
144
123
class TreeEntry(object):
145
124
    """An entry that implements the minimum interface used by commands.
146
125
 
428
407
    def _cleanup(self):
429
408
        self._flush_ignore_list_cache()
430
409
 
431
 
    @staticmethod
432
 
    @deprecated_method(zero_eight)
433
 
    def create(branch, directory):
434
 
        """Create a workingtree for branch at directory.
435
 
 
436
 
        If existing_directory already exists it must have a .bzr directory.
437
 
        If it does not exist, it will be created.
438
 
 
439
 
        This returns a new WorkingTree object for the new checkout.
440
 
 
441
 
        TODO FIXME RBC 20060124 when we have checkout formats in place this
442
 
        should accept an optional revisionid to checkout [and reject this if
443
 
        checking out into the same dir as a pre-checkout-aware branch format.]
444
 
 
445
 
        XXX: When BzrDir is present, these should be created through that 
446
 
        interface instead.
447
 
        """
448
 
        warnings.warn('delete WorkingTree.create', stacklevel=3)
449
 
        transport = get_transport(directory)
450
 
        if branch.bzrdir.root_transport.base == transport.base:
451
 
            # same dir 
452
 
            return branch.bzrdir.create_workingtree()
453
 
        # different directory, 
454
 
        # create a branch reference
455
 
        # and now a working tree.
456
 
        raise NotImplementedError
457
 
 
458
 
    @staticmethod
459
 
    @deprecated_method(zero_eight)
460
 
    def create_standalone(directory):
461
 
        """Create a checkout and a branch and a repo at directory.
462
 
 
463
 
        Directory must exist and be empty.
464
 
 
465
 
        please use BzrDir.create_standalone_workingtree
466
 
        """
467
 
        return bzrdir.BzrDir.create_standalone_workingtree(directory)
468
 
 
469
410
    def relpath(self, path):
470
411
        """Return the local path portion from a given path.
471
412
        
612
553
    __contains__ = has_id
613
554
 
614
555
    def get_file_size(self, file_id):
615
 
        return os.path.getsize(self.id2abspath(file_id))
 
556
        """See Tree.get_file_size"""
 
557
        try:
 
558
            return os.path.getsize(self.id2abspath(file_id))
 
559
        except OSError, e:
 
560
            if e.errno != errno.ENOENT:
 
561
                raise
 
562
            else:
 
563
                return None
616
564
 
617
565
    @needs_read_lock
618
566
    def get_file_sha1(self, file_id, path=None, stat_value=None):
758
706
        else:
759
707
            return (kind, None, None, None)
760
708
 
761
 
    @deprecated_method(zero_eleven)
762
 
    @needs_read_lock
763
 
    def pending_merges(self):
764
 
        """Return a list of pending merges.
765
 
 
766
 
        These are revisions that have been merged into the working
767
 
        directory but not yet committed.
768
 
 
769
 
        As of 0.11 this is deprecated. Please see WorkingTree.get_parent_ids()
770
 
        instead - which is available on all tree objects.
771
 
        """
772
 
        return self.get_parent_ids()[1:]
773
 
 
774
709
    def _check_parents_for_ghosts(self, revision_ids, allow_leftmost_as_ghost):
775
710
        """Common ghost checking functionality from set_parent_*.
776
711
 
1533
1468
            # - RBC 20060907
1534
1469
            self._write_inventory(self._inventory)
1535
1470
    
1536
 
    @deprecated_method(zero_eight)
1537
 
    def iter_conflicts(self):
1538
 
        """List all files in the tree that have text or content conflicts.
1539
 
        DEPRECATED.  Use conflicts instead."""
1540
 
        return self._iter_conflicts()
1541
 
 
1542
1471
    def _iter_conflicts(self):
1543
1472
        conflicted = set()
1544
1473
        for info in self.list_files():
2083
2012
        """Set the root id for this tree."""
2084
2013
        # for compatability 
2085
2014
        if file_id is None:
2086
 
            symbol_versioning.warn(symbol_versioning.zero_twelve
2087
 
                % 'WorkingTree.set_root_id with fileid=None',
2088
 
                DeprecationWarning,
2089
 
                stacklevel=3)
2090
 
            file_id = ROOT_ID
2091
 
        else:
2092
 
            file_id = osutils.safe_file_id(file_id)
 
2015
            raise ValueError(
 
2016
                'WorkingTree.set_root_id with fileid=None')
 
2017
        file_id = osutils.safe_file_id(file_id)
2093
2018
        self._set_root_id(file_id)
2094
2019
 
2095
2020
    def _set_root_id(self, file_id):
2637
2562
            return path[:-len(suffix)]
2638
2563
 
2639
2564
 
2640
 
@deprecated_function(zero_eight)
2641
 
def is_control_file(filename):
2642
 
    """See WorkingTree.is_control_filename(filename)."""
2643
 
    ## FIXME: better check
2644
 
    filename = normpath(filename)
2645
 
    while filename != '':
2646
 
        head, tail = os.path.split(filename)
2647
 
        ## mutter('check %r for control file' % ((head, tail),))
2648
 
        if tail == '.bzr':
2649
 
            return True
2650
 
        if filename == head:
2651
 
            break
2652
 
        filename = head
2653
 
    return False
2654
 
 
2655
 
 
2656
2565
class WorkingTreeFormat(object):
2657
2566
    """An encapsulation of the initialization and open routines for a format.
2658
2567