/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

Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
702
702
        if updated:
703
703
            self.set_parent_ids(parents, allow_leftmost_as_ghost=True)
704
704
 
 
705
    def path_content_summary(self, path, _lstat=osutils.lstat,
 
706
        _mapper=osutils.file_kind_from_stat_mode):
 
707
        """See Tree.path_content_summary."""
 
708
        abspath = self.abspath(path)
 
709
        try:
 
710
            stat_result = _lstat(abspath)
 
711
        except OSError, e:
 
712
            if getattr(e, 'errno', None) == errno.ENOENT:
 
713
                # no file.
 
714
                return ('missing', None, None, None)
 
715
            # propagate other errors
 
716
            raise
 
717
        kind = _mapper(stat_result.st_mode)
 
718
        if kind == 'file':
 
719
            size = stat_result.st_size
 
720
            # try for a stat cache lookup
 
721
            if not supports_executable():
 
722
                executable = None # caller can decide policy.
 
723
            else:
 
724
                mode = stat_result.st_mode
 
725
                executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
 
726
            return (kind, size, executable, self._sha_from_stat(
 
727
                path, stat_result))
 
728
        elif kind == 'directory':
 
729
            # perhaps it looks like a plain directory, but it's really a
 
730
            # reference.
 
731
            if self._directory_is_tree_reference(path):
 
732
                kind = 'tree-reference'
 
733
            return kind, None, None, None
 
734
        elif kind == 'symlink':
 
735
            return ('symlink', None, None, os.readlink(abspath))
 
736
        else:
 
737
            return (kind, None, None, None)
 
738
 
705
739
    @deprecated_method(zero_eleven)
706
740
    @needs_read_lock
707
741
    def pending_merges(self):
799
833
                yield Stanza(file_id=file_id.decode('utf8'), hash=hash)
800
834
        self._put_rio('merge-hashes', iter_stanzas(), MERGE_MODIFIED_HEADER_1)
801
835
 
 
836
    def _sha_from_stat(self, path, stat_result):
 
837
        """Get a sha digest from the tree's stat cache.
 
838
 
 
839
        The default implementation assumes no stat cache is present.
 
840
 
 
841
        :param path: The path.
 
842
        :param stat_result: The stat result being looked up.
 
843
        """
 
844
        return None
 
845
 
802
846
    def _put_rio(self, filename, stanzas, header):
803
847
        self._must_be_locked()
804
848
        my_file = rio_file(stanzas, header)
943
987
            other_tree.unlock()
944
988
        other_tree.bzrdir.retire_bzrdir()
945
989
 
 
990
    def _directory_is_tree_reference(self, relpath):
 
991
        # as a special case, if a directory contains control files then 
 
992
        # it's a tree reference, except that the root of the tree is not
 
993
        return relpath and osutils.isdir(self.abspath(relpath) + u"/.bzr")
 
994
        # TODO: We could ask all the control formats whether they
 
995
        # recognize this directory, but at the moment there's no cheap api
 
996
        # to do that.  Since we probably can only nest bzr checkouts and
 
997
        # they always use this name it's ok for now.  -- mbp 20060306
 
998
        #
 
999
        # FIXME: There is an unhandled case here of a subdirectory
 
1000
        # containing .bzr but not a branch; that will probably blow up
 
1001
        # when you try to commit it.  It might happen if there is a
 
1002
        # checkout in a subdirectory.  This can be avoided by not adding
 
1003
        # it.  mbp 20070306
 
1004
 
946
1005
    @needs_tree_write_lock
947
1006
    def extract(self, file_id, format=None):
948
1007
        """Extract a subtree from this tree.
995
1054
        return wt
996
1055
 
997
1056
    def _serialize(self, inventory, out_file):
998
 
        xml5.serializer_v5.write_inventory(self._inventory, out_file)
 
1057
        xml5.serializer_v5.write_inventory(self._inventory, out_file,
 
1058
            working=True)
999
1059
 
1000
1060
    def _deserialize(selt, in_file):
1001
1061
        return xml5.serializer_v5.read_inventory(in_file)
1462
1522
 
1463
1523
    @needs_write_lock
1464
1524
    def pull(self, source, overwrite=False, stop_revision=None,
1465
 
             change_reporter=None):
 
1525
             change_reporter=None, possible_transports=None):
1466
1526
        top_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1467
1527
        source.lock_read()
1468
1528
        try:
1470
1530
            pp.next_phase()
1471
1531
            old_revision_info = self.branch.last_revision_info()
1472
1532
            basis_tree = self.basis_tree()
1473
 
            count = self.branch.pull(source, overwrite, stop_revision)
 
1533
            count = self.branch.pull(source, overwrite, stop_revision,
 
1534
                                     possible_transports=possible_transports)
1474
1535
            new_revision_info = self.branch.last_revision_info()
1475
1536
            if new_revision_info != old_revision_info:
1476
1537
                pp.next_phase()
1903
1964
        self.apply_inventory_delta(inv_delta)
1904
1965
 
1905
1966
    @needs_tree_write_lock
1906
 
    def revert(self, filenames, old_tree=None, backups=True, 
 
1967
    def revert(self, filenames=None, old_tree=None, backups=True,
1907
1968
               pb=DummyProgress(), report_changes=False):
1908
1969
        from bzrlib.conflicts import resolve
 
1970
        if filenames == []:
 
1971
            filenames = None
 
1972
            symbol_versioning.warn('Using [] to revert all files is deprecated'
 
1973
                ' as of bzr 0.91.  Please use None (the default) instead.',
 
1974
                DeprecationWarning, stacklevel=2)
1909
1975
        if old_tree is None:
1910
1976
            old_tree = self.basis_tree()
1911
1977
        conflicts = transform.revert(self, old_tree, filenames, backups, pb,
1912
1978
                                     report_changes)
1913
 
        if not len(filenames):
 
1979
        if filenames is None:
1914
1980
            self.set_parent_ids(self.get_parent_ids()[:1])
1915
1981
            resolve(self)
1916
1982
        else:
2017
2083
        """
2018
2084
        raise NotImplementedError(self.unlock)
2019
2085
 
2020
 
    def update(self, change_reporter=None):
 
2086
    def update(self, change_reporter=None, possible_transports=None):
2021
2087
        """Update a working tree along its branch.
2022
2088
 
2023
2089
        This will update the branch if its bound too, which means we have
2042
2108
          basis.
2043
2109
        - Do a 'normal' merge of the old branch basis if it is relevant.
2044
2110
        """
2045
 
        if self.branch.get_master_branch() is not None:
 
2111
        if self.branch.get_master_branch(possible_transports) is not None:
2046
2112
            self.lock_write()
2047
2113
            update_branch = True
2048
2114
        else:
2050
2116
            update_branch = False
2051
2117
        try:
2052
2118
            if update_branch:
2053
 
                old_tip = self.branch.update()
 
2119
                old_tip = self.branch.update(possible_transports)
2054
2120
            else:
2055
2121
                old_tip = None
2056
2122
            return self._update_tree(old_tip, change_reporter)
2635
2701
        """
2636
2702
        sio = StringIO()
2637
2703
        inv = Inventory()
2638
 
        xml5.serializer_v5.write_inventory(inv, sio)
 
2704
        xml5.serializer_v5.write_inventory(inv, sio, working=True)
2639
2705
        sio.seek(0)
2640
2706
        control_files.put('inventory', sio)
2641
2707