~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-04 16:50:33 UTC
  • mto: This revision was merged to the branch mainline in revision 4410.
  • Revision ID: john@arbash-meinel.com-20090604165033-bfdo0lyf4yt4vjcz
We don't need a base Coder class, because Decoder._update_tail is different than Encoder._update_tail.
(one adds, one subtracts from self.size).
So we now have 2 versions of the macro, and the test suite stops crashing... :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
451
451
            path = self.id2path(file_id)
452
452
        file_obj = self.get_file_byname(path, filtered=False)
453
453
        stat_value = _fstat(file_obj.fileno())
454
 
        if filtered and self.supports_content_filtering():
 
454
        if self.supports_content_filtering() and filtered:
455
455
            filters = self._content_filter_stack(path)
456
456
            file_obj = filtered_input_file(file_obj, filters)
457
457
        return (file_obj, stat_value)
462
462
    def get_file_byname(self, filename, filtered=True):
463
463
        path = self.abspath(filename)
464
464
        f = file(path, 'rb')
465
 
        if filtered and self.supports_content_filtering():
 
465
        if self.supports_content_filtering() and filtered:
466
466
            filters = self._content_filter_stack(filename)
467
467
            return filtered_input_file(f, filters)
468
468
        else:
1115
1115
    def _kind(self, relpath):
1116
1116
        return osutils.file_kind(self.abspath(relpath))
1117
1117
 
1118
 
    def list_files(self, include_root=False, from_dir=None, recursive=True):
1119
 
        """List all files as (path, class, kind, id, entry).
 
1118
    def list_files(self, include_root=False):
 
1119
        """Recursively list all files as (path, class, kind, id, entry).
1120
1120
 
1121
1121
        Lists, but does not descend into unversioned directories.
 
1122
 
1122
1123
        This does not include files that have been deleted in this
1123
 
        tree. Skips the control directory.
 
1124
        tree.
1124
1125
 
1125
 
        :param include_root: if True, do not return an entry for the root
1126
 
        :param from_dir: start from this directory or None for the root
1127
 
        :param recursive: whether to recurse into subdirectories or not
 
1126
        Skips the control directory.
1128
1127
        """
1129
1128
        # list_files is an iterator, so @needs_read_lock doesn't work properly
1130
1129
        # with it. So callers should be careful to always read_lock the tree.
1132
1131
            raise errors.ObjectNotLocked(self)
1133
1132
 
1134
1133
        inv = self.inventory
1135
 
        if from_dir is None and include_root is True:
 
1134
        if include_root is True:
1136
1135
            yield ('', 'V', 'directory', inv.root.file_id, inv.root)
1137
1136
        # Convert these into local objects to save lookup times
1138
1137
        pathjoin = osutils.pathjoin
1145
1144
        fk_entries = {'directory':TreeDirectory, 'file':TreeFile, 'symlink':TreeLink}
1146
1145
 
1147
1146
        # directory file_id, relative path, absolute path, reverse sorted children
1148
 
        if from_dir is not None:
1149
 
            from_dir_id = inv.path2id(from_dir)
1150
 
            if from_dir_id is None:
1151
 
                # Directory not versioned
1152
 
                return
1153
 
            from_dir_abspath = pathjoin(self.basedir, from_dir)
1154
 
        else:
1155
 
            from_dir_id = inv.root.file_id
1156
 
            from_dir_abspath = self.basedir
1157
 
        children = os.listdir(from_dir_abspath)
 
1147
        children = os.listdir(self.basedir)
1158
1148
        children.sort()
1159
1149
        # jam 20060527 The kernel sized tree seems equivalent whether we
1160
1150
        # use a deque and popleft to keep them sorted, or if we use a plain
1161
1151
        # list and just reverse() them.
1162
1152
        children = collections.deque(children)
1163
 
        stack = [(from_dir_id, u'', from_dir_abspath, children)]
 
1153
        stack = [(inv.root.file_id, u'', self.basedir, children)]
1164
1154
        while stack:
1165
1155
            from_dir_id, from_dir_relpath, from_dir_abspath, children = stack[-1]
1166
1156
 
1224
1214
                if fk != 'directory':
1225
1215
                    continue
1226
1216
 
1227
 
                # But do this child first if recursing down
1228
 
                if recursive:
1229
 
                    new_children = os.listdir(fap)
1230
 
                    new_children.sort()
1231
 
                    new_children = collections.deque(new_children)
1232
 
                    stack.append((f_ie.file_id, fp, fap, new_children))
1233
 
                    # Break out of inner loop,
1234
 
                    # so that we start outer loop with child
1235
 
                    break
 
1217
                # But do this child first
 
1218
                new_children = os.listdir(fap)
 
1219
                new_children.sort()
 
1220
                new_children = collections.deque(new_children)
 
1221
                stack.append((f_ie.file_id, fp, fap, new_children))
 
1222
                # Break out of inner loop,
 
1223
                # so that we start outer loop with child
 
1224
                break
1236
1225
            else:
1237
1226
                # if we finished all children, pop it off the stack
1238
1227
                stack.pop()