/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/commit.py

  • Committer: Jelmer Vernooij
  • Date: 2020-06-23 01:42:20 UTC
  • mto: This revision was merged to the branch mainline in revision 7518.
  • Revision ID: jelmer@jelmer.uk-20200623014220-l8z31ermpu2apkee
Update installation instructions, explaining need for Python 3.5+ and optional dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from dulwich.index import (
21
21
    commit_tree,
22
 
    read_submodule_head,
23
22
    )
24
23
import stat
25
24
 
43
42
    Blob,
44
43
    Commit,
45
44
    )
 
45
from dulwich.index import read_submodule_head
46
46
 
47
47
 
48
48
from .mapping import (
49
 
    encode_git_path,
50
49
    object_mode,
51
50
    fix_person_identifier,
52
51
    )
75
74
    def record_iter_changes(self, workingtree, basis_revid, iter_changes):
76
75
        seen_root = False
77
76
        for change in iter_changes:
78
 
            if change.kind == (None, None):
79
 
                # Ephemeral
80
 
                continue
81
 
            if change.versioned[0] and not change.copied:
82
 
                file_id = self._mapping.generate_file_id(change.path[0])
83
 
            elif change.versioned[1]:
84
 
                file_id = self._mapping.generate_file_id(change.path[1])
85
 
            else:
86
 
                file_id = None
87
 
            if change.path[1]:
88
 
                parent_id_new = self._mapping.generate_file_id(osutils.dirname(change.path[1]))
89
 
            else:
90
 
                parent_id_new = None
91
77
            if change.kind[1] in ("directory",):
92
78
                self._inv_delta.append(
93
 
                    (change.path[0], change.path[1], file_id,
 
79
                    (change.path[0], change.path[1], change.file_id,
94
80
                     entry_factory[change.kind[1]](
95
 
                         file_id, change.name[1], parent_id_new)))
 
81
                         change.file_id, change.name[1], change.parent_id[1])))
96
82
                if change.kind[0] in ("file", "symlink"):
97
 
                    self._blobs[encode_git_path(change.path[0])] = None
 
83
                    self._blobs[change.path[0].encode("utf-8")] = None
98
84
                    self._any_changes = True
99
85
                if change.path[1] == "":
100
86
                    seen_root = True
101
87
                continue
102
88
            self._any_changes = True
103
89
            if change.path[1] is None:
104
 
                self._inv_delta.append((change.path[0], change.path[1], file_id, None))
105
 
                self._deleted_paths.add(encode_git_path(change.path[0]))
 
90
                self._inv_delta.append((change.path[0], change.path[1], change.file_id, None))
 
91
                self._deleted_paths.add(change.path[0].encode("utf-8"))
106
92
                continue
107
93
            try:
108
94
                entry_kls = entry_factory[change.kind[1]]
109
95
            except KeyError:
110
96
                raise KeyError("unknown kind %s" % change.kind[1])
111
 
            entry = entry_kls(file_id, change.name[1], parent_id_new)
 
97
            entry = entry_kls(change.file_id, change.name[1], change.parent_id[1])
112
98
            if change.kind[1] == "file":
113
99
                entry.executable = change.executable[1]
114
100
                blob = Blob()
117
103
                    blob.data = f.read()
118
104
                finally:
119
105
                    f.close()
 
106
                entry.text_size = len(blob.data)
 
107
                entry.text_sha1 = osutils.sha_string(blob.data)
 
108
                self.store.add_object(blob)
120
109
                sha = blob.id
121
 
                if st is not None:
122
 
                    entry.text_size = st.st_size
123
 
                else:
124
 
                    entry.text_size = len(blob.data)
125
 
                entry.git_sha1 = sha
126
 
                self.store.add_object(blob)
127
110
            elif change.kind[1] == "symlink":
128
111
                symlink_target = workingtree.get_symlink_target(change.path[1])
129
112
                blob = Blob()
130
 
                blob.data = encode_git_path(symlink_target)
 
113
                blob.data = symlink_target.encode("utf-8")
131
114
                self.store.add_object(blob)
132
115
                sha = blob.id
133
116
                entry.symlink_target = symlink_target
140
123
            else:
141
124
                raise AssertionError("Unknown kind %r" % change.kind[1])
142
125
            mode = object_mode(change.kind[1], change.executable[1])
143
 
            self._inv_delta.append((change.path[0], change.path[1], file_id, entry))
 
126
            self._inv_delta.append((change.path[0], change.path[1], change.file_id, entry))
144
127
            if change.path[0] is not None:
145
 
                self._deleted_paths.add(encode_git_path(change.path[0]))
146
 
            self._blobs[encode_git_path(change.path[1])] = (mode, sha)
 
128
                self._deleted_paths.add(change.path[0].encode("utf-8"))
 
129
            self._blobs[change.path[1].encode("utf-8")] = (mode, sha)
147
130
            if st is not None:
148
 
                yield change.path[1], (entry.git_sha1, st)
 
131
                yield change.path[1], (entry.text_sha1, st)
149
132
        if not seen_root and len(self.parents) == 0:
150
133
            raise RootMissing()
151
134
        if getattr(workingtree, "basis_tree", False):