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

  • Committer: Jelmer Vernooij
  • Date: 2018-05-21 20:57:42 UTC
  • mto: This revision was merged to the branch mainline in revision 6974.
  • Revision ID: jelmer@jelmer.uk-20180521205742-ix1prudgq6raokjv
Make InterIndexGitTree suitable for use with MemoryGitTree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import posixpath
24
24
import stat
25
25
 
 
26
from dulwich.index import (
 
27
    index_entry_from_stat,
 
28
    )
26
29
from dulwich.objects import (
 
30
    Blob,
27
31
    Tree,
28
32
    )
29
33
 
171
175
            (mem_stat.st_mode, 0, 0, 0, 0, 0, mem_stat.st_size, 0, 0, 0))
172
176
        return stat_val
173
177
 
 
178
    def _live_entry(self, path):
 
179
        stat_val = self._lstat(path)
 
180
        if stat.S_ISDIR(stat_val.st_mode):
 
181
            return None
 
182
        elif stat.S_ISLNK(stat_val.st_mode):
 
183
            blob = Blob.from_string(self._file_transport.readlink(path))
 
184
        elif stat.S_ISREG(stat_val.st_mode):
 
185
            blob = Blob.from_string(self._file_transport.get_bytes(path))
 
186
        else:
 
187
            raise AssertionError('unknown type %d' % stat_val.st_mode)
 
188
        return index_entry_from_stat(stat_val, blob.id, 0)
 
189
 
174
190
    def get_file_with_stat(self, path, file_id=None):
175
191
        return (self.get_file(path, file_id), self._lstat(path))
176
192