/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_4.py

Add a tree-test for get_symlink_target
and implement it in DirStateRevisionTree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1050
1050
        pred = self.has_filename
1051
1051
        return set((p for p in paths if not pred(p)))
1052
1052
 
 
1053
    def _get_parent_index(self):
 
1054
        """Return the index in the dirstate referenced by this tree."""
 
1055
        return self._dirstate.get_parent_ids().index(self._revision_id) + 1
 
1056
 
1053
1057
    def _get_entry(self, file_id=None, path=None):
1054
1058
        """Get the dirstate row for file_id or path.
1055
1059
 
1066
1070
        file_id = osutils.safe_file_id(file_id)
1067
1071
        if path is not None:
1068
1072
            path = path.encode('utf8')
1069
 
        parent_index = self._dirstate.get_parent_ids().index(self._revision_id) + 1
 
1073
        parent_index = self._get_parent_index()
1070
1074
        return self._dirstate._get_entry(parent_index, fileid_utf8=file_id, path_utf8=path)
1071
1075
 
1072
1076
    def _generate_inventory(self):
1157
1161
    def get_file_text(self, file_id):
1158
1162
        return ''.join(self.get_file_lines(file_id))
1159
1163
 
 
1164
    def get_symlink_target(self, file_id):
 
1165
        entry = self._get_entry(file_id=file_id)
 
1166
        parent_index = self._get_parent_index()
 
1167
        if entry[1][parent_index][0] != 'l':
 
1168
            return None
 
1169
        else:
 
1170
            # At present, none of the tree implementations supports non-ascii
 
1171
            # symlink targets. So we will just assume that the dirstate path is
 
1172
            # correct.
 
1173
            return entry[1][parent_index][1]
 
1174
 
1160
1175
    def get_revision_id(self):
1161
1176
        """Return the revision id for this tree."""
1162
1177
        return self._revision_id