/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
See MemoryTree for more details.
20
20
"""
21
21
 
22
 
from __future__ import absolute_import
23
 
 
24
22
import os
 
23
import stat
25
24
 
26
25
from . import (
27
26
    errors,
50
49
        self._locks = 0
51
50
        self._lock_mode = None
52
51
 
 
52
    def supports_symlinks(self):
 
53
        return True
 
54
 
 
55
    def supports_tree_reference(self):
 
56
        return False
 
57
 
53
58
    def get_config_stack(self):
54
59
        return self.branch.get_config_stack()
55
60
 
62
67
        with self.lock_tree_write():
63
68
            for f, file_id, kind in zip(files, ids, kinds):
64
69
                if kind is None:
65
 
                    kind = 'file'
 
70
                    st_mode = self._file_transport.stat(f).st_mode
 
71
                    if stat.S_ISREG(st_mode):
 
72
                        kind = 'file'
 
73
                    elif stat.S_ISLNK(st_mode):
 
74
                        kind = 'symlink'
 
75
                    elif stat.S_ISDIR(st_mode):
 
76
                        kind = 'directory'
 
77
                    else:
 
78
                        raise AssertionError('Unknown file kind')
66
79
                if file_id is None:
67
80
                    self._inventory.add_path(f, kind=kind)
68
81
                else:
85
98
        missing files, so is a no-op.
86
99
        """
87
100
 
88
 
    def get_file(self, path, file_id=None):
 
101
    def get_file(self, path):
89
102
        """See Tree.get_file."""
90
103
        return self._file_transport.get(path)
91
104
 
92
 
    def get_file_sha1(self, path, file_id=None, stat_value=None):
 
105
    def get_file_sha1(self, path, stat_value=None):
93
106
        """See Tree.get_file_sha1()."""
94
107
        stream = self._file_transport.get(path)
95
108
        return sha_file(stream)
96
109
 
97
 
    def get_root_id(self):
98
 
        return self.path2id('')
99
 
 
100
110
    def _comparison_data(self, entry, path):
101
111
        """See Tree._comparison_data."""
102
112
        if entry is None:
127
137
            # memory tree does not support nested trees yet.
128
138
            return kind, None, None, None
129
139
        elif kind == 'symlink':
130
 
            raise NotImplementedError('symlink support')
 
140
            return kind, None, None, self._inventory[id].symlink_target
131
141
        else:
132
142
            raise NotImplementedError('unknown kind')
133
143
 
147
157
    def is_executable(self, path):
148
158
        return self._inventory.get_entry_by_path(path).executable
149
159
 
150
 
    def kind(self, path, file_id=None):
151
 
        if file_id is None:
152
 
            file_id = self.path2id(path)
153
 
        return self._inventory[file_id].kind
 
160
    def kind(self, path):
 
161
        return self._inventory.get_entry_by_path(path).kind
154
162
 
155
163
    def mkdir(self, path, file_id=None):
156
164
        """See MutableTree.mkdir()."""
228
236
                continue
229
237
            if entry.kind == 'directory':
230
238
                self._file_transport.mkdir(path)
 
239
            elif entry.kind == 'symlink':
 
240
                self._file_transport.symlink(entry.symlink_target, path)
231
241
            elif entry.kind == 'file':
232
242
                self._file_transport.put_file(
233
243
                    path, self._basis_tree.get_file(path))
234
244
            else:
235
245
                raise NotImplementedError(self._populate_from_branch)
236
246
 
237
 
    def put_file_bytes_non_atomic(self, path, bytes, file_id=None):
 
247
    def put_file_bytes_non_atomic(self, path, bytes):
238
248
        """See MutableTree.put_file_bytes_non_atomic."""
239
249
        self._file_transport.put_bytes(path, bytes)
240
250
 
256
266
        else:
257
267
            self._locks -= 1
258
268
 
259
 
    def unversion(self, paths, file_ids=None):
 
269
    def unversion(self, paths):
260
270
        """Remove the paths from the current versioned set.
261
271
 
262
272
        When a file_id is unversioned, all of its children are automatically
269
279
            # XXX: This should be in mutabletree, but the inventory-save action
270
280
            # is not relevant to memory tree. Until that is done in unlock by
271
281
            # working tree, we cannot share the implementation.
272
 
            if file_ids is None:
273
 
                file_ids = set()
274
 
                for path in paths:
275
 
                    file_id = self.path2id(path)
276
 
                    if file_id is None:
277
 
                        raise errors.NoSuchFile(path)
278
 
                    file_ids.add(file_id)
279
 
            else:
280
 
                for file_id in file_ids:
281
 
                    if not self._inventory.has_id(file_id):
282
 
                        raise errors.NoSuchId(self, file_id)
 
282
            file_ids = set()
 
283
            for path in paths:
 
284
                file_id = self.path2id(path)
 
285
                if file_id is None:
 
286
                    raise errors.NoSuchFile(path)
 
287
                file_ids.add(file_id)
283
288
            for file_id in file_ids:
284
289
                if self._inventory.has_id(file_id):
285
290
                    self._inventory.remove_recursive_id(file_id)
308
313
            else:
309
314
                raise
310
315
 
 
316
    def get_symlink_target(self, path):
 
317
        with self.lock_read():
 
318
            return self._file_transport.readlink(path)
 
319
 
311
320
    def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
312
321
        """See MutableTree.set_parent_trees()."""
313
322
        if len(parents_list) == 0: