/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/git/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:
17
17
 
18
18
"""Git Memory Trees."""
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
20
import os
23
21
import posixpath
24
22
import stat
41
39
    )
42
40
from breezy.transport.memory import MemoryTransport
43
41
 
44
 
from .mapping import GitFileIdMap
 
42
from .mapping import (
 
43
    decode_git_path,
 
44
    encode_git_path,
 
45
    )
45
46
from .tree import MutableGitIndexTree
46
47
 
47
48
 
58
59
        self._lock_mode = None
59
60
        self._populate_from_branch()
60
61
 
 
62
    def _supports_executable(self):
 
63
        return True
 
64
 
61
65
    @property
62
66
    def controldir(self):
63
67
        return self.branch.controldir
73
77
                if kinds[pos] is None:
74
78
                    kinds[pos] = self.kind(f)
75
79
 
76
 
    def put_file_bytes_non_atomic(self, path, bytes, file_id=None):
 
80
    def put_file_bytes_non_atomic(self, path, bytes):
77
81
        """See MutableTree.put_file_bytes_non_atomic."""
78
82
        self._file_transport.put_bytes(path, bytes)
79
83
 
86
90
        self._file_transport = MemoryTransport()
87
91
        if self.branch.head is None:
88
92
            tree = Tree()
89
 
            self._basis_fileid_map = GitFileIdMap({}, self.mapping)
90
93
        else:
91
94
            tree_id = self.store[self.branch.head].tree
92
 
            self._basis_fileid_map = self.mapping.get_fileid_map(
93
 
                self.store.__getitem__, tree_id)
94
95
            tree = self.store[tree_id]
95
 
        self._fileid_map = self._basis_fileid_map.copy()
96
96
 
97
97
        trees = [("", tree)]
98
98
        while trees:
99
99
            (path, tree) = trees.pop()
100
100
            for name, mode, sha in tree.iteritems():
101
 
                subpath = posixpath.join(path, name.decode('utf-8'))
 
101
                subpath = posixpath.join(path, decode_git_path(name))
102
102
                if stat.S_ISDIR(mode):
103
103
                    self._file_transport.mkdir(subpath)
104
104
                    trees.append((subpath, self.store[sha]))
185
185
            return None
186
186
        elif stat.S_ISLNK(stat_val.st_mode):
187
187
            blob = Blob.from_string(
188
 
                self._file_transport.readlink(path).encode('utf-8'))
 
188
                encode_git_path(self._file_transport.readlink(path)))
189
189
        elif stat.S_ISREG(stat_val.st_mode):
190
190
            blob = Blob.from_string(self._file_transport.get_bytes(path))
191
191
        else:
192
192
            raise AssertionError('unknown type %d' % stat_val.st_mode)
193
193
        return index_entry_from_stat(stat_val, blob.id, 0)
194
194
 
195
 
    def get_file_with_stat(self, path, file_id=None):
196
 
        return (self.get_file(path, file_id), self._lstat(path))
 
195
    def get_file_with_stat(self, path):
 
196
        return (self.get_file(path), self._lstat(path))
197
197
 
198
 
    def get_file(self, path, file_id=None):
 
198
    def get_file(self, path):
199
199
        """See Tree.get_file."""
200
200
        return self._file_transport.get(path)
201
201
 
202
 
    def get_file_sha1(self, path, file_id=None, stat_value=None):
 
202
    def get_file_sha1(self, path, stat_value=None):
203
203
        """See Tree.get_file_sha1()."""
204
204
        stream = self._file_transport.get(path)
205
205
        return osutils.sha_file(stream)
258
258
    def kind(self, p):
259
259
        stat_value = self._file_transport.stat(p)
260
260
        return osutils.file_kind_from_stat_mode(stat_value.st_mode)
 
261
 
 
262
    def get_symlink_target(self, path):
 
263
        with self.lock_read():
 
264
            return self._file_transport.readlink(path)