/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 breezy/memorytree.py

  • Committer: Jelmer Vernooij
  • Date: 2017-11-19 18:35:20 UTC
  • mfrom: (6809.4.27 swap-arguments)
  • Revision ID: jelmer@jelmer.uk-20171119183520-fmw89uw30e0tbhwz
Merge lp:~jelmer/brz/swap-arguments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
        missing files, so is a no-op.
86
86
        """
87
87
 
88
 
    def get_file(self, file_id, path=None):
 
88
    def get_file(self, path, file_id=None):
89
89
        """See Tree.get_file."""
90
 
        if path is None:
91
 
            path = self.id2path(file_id)
92
90
        return self._file_transport.get(path)
93
91
 
94
 
    def get_file_sha1(self, file_id, path=None, stat_value=None):
 
92
    def get_file_sha1(self, path, file_id=None, stat_value=None):
95
93
        """See Tree.get_file_sha1()."""
96
 
        if path is None:
97
 
            path = self.id2path(file_id)
98
94
        stream = self._file_transport.get(path)
99
95
        return sha_file(stream)
100
96
 
120
116
        id = self.path2id(path)
121
117
        if id is None:
122
118
            return 'missing', None, None, None
123
 
        kind = self.kind(id)
 
119
        kind = self.kind(path, id)
124
120
        if kind == 'file':
125
121
            bytes = self._file_transport.get_bytes(path)
126
122
            size = len(bytes)
154
150
        """See Tree.has_filename()."""
155
151
        return self._file_transport.has(filename)
156
152
 
157
 
    def is_executable(self, file_id, path=None):
 
153
    def is_executable(self, path, file_id=None):
158
154
        return self._inventory[file_id].executable
159
155
 
160
 
    def kind(self, file_id):
 
156
    def kind(self, path, file_id=None):
 
157
        if file_id is None:
 
158
            file_id = self.path2id(path)
161
159
        return self._inventory[file_id].kind
162
160
 
163
161
    def mkdir(self, path, file_id=None):
238
236
                self._file_transport.mkdir(path)
239
237
            elif entry.kind == 'file':
240
238
                self._file_transport.put_file(path,
241
 
                    self._basis_tree.get_file(entry.file_id))
 
239
                    self._basis_tree.get_file(path, entry.file_id))
242
240
            else:
243
241
                raise NotImplementedError(self._populate_from_branch)
244
242
 
245
 
    def put_file_bytes_non_atomic(self, file_id, bytes):
 
243
    def put_file_bytes_non_atomic(self, path, bytes, file_id=None):
246
244
        """See MutableTree.put_file_bytes_non_atomic."""
247
 
        self._file_transport.put_bytes(self.id2path(file_id), bytes)
 
245
        self._file_transport.put_bytes(path, bytes)
248
246
 
249
247
    def unlock(self):
250
248
        """Release a lock.
264
262
        else:
265
263
            self._locks -= 1
266
264
 
267
 
    def unversion(self, file_ids):
268
 
        """Remove the file ids in file_ids from the current versioned set.
 
265
    def unversion(self, paths, file_ids=None):
 
266
        """Remove the paths from the current versioned set.
269
267
 
270
268
        When a file_id is unversioned, all of its children are automatically
271
269
        unversioned.
272
270
 
273
 
        :param file_ids: The file ids to stop versioning.
 
271
        :param paths: The paths to stop versioning.
274
272
        :raises: NoSuchId if any fileid is not currently versioned.
275
273
        """
276
274
        with self.lock_tree_write():
277
275
            # XXX: This should be in mutabletree, but the inventory-save action
278
276
            # is not relevant to memory tree. Until that is done in unlock by
279
277
            # working tree, we cannot share the implementation.
 
278
            if file_ids is None:
 
279
                file_ids = {self.path2id(path) for path in paths}
280
280
            for file_id in file_ids:
281
281
                if self._inventory.has_id(file_id):
282
282
                    self._inventory.remove_recursive_id(file_id)