/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-07-04 00:13:42 UTC
  • mto: (7490.40.45 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200704001342-24rw9hhy90lhmpa6
Add a code of conduct.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
 
53
53
from .mapping import (
 
54
    encode_git_path,
54
55
    object_mode,
55
56
    fix_person_identifier,
56
57
    )
69
70
        self.store = self.repository._git.object_store
70
71
        self._blobs = {}
71
72
        self._inv_delta = []
 
73
        self._deleted_paths = set()
72
74
        self._any_changes = False
73
75
        self._mapping = self.repository.get_mapping()
74
76
 
84
86
                     entry_factory[change.kind[1]](
85
87
                         change.file_id, change.name[1], change.parent_id[1])))
86
88
                if change.kind[0] in ("file", "symlink"):
87
 
                    self._blobs[change.path[0].encode("utf-8")] = None
 
89
                    self._blobs[encode_git_path(change.path[0])] = None
88
90
                    self._any_changes = True
89
91
                if change.path[1] == "":
90
92
                    seen_root = True
92
94
            self._any_changes = True
93
95
            if change.path[1] is None:
94
96
                self._inv_delta.append((change.path[0], change.path[1], change.file_id, None))
95
 
                self._blobs[change.path[0].encode("utf-8")] = None
 
97
                self._deleted_paths.add(encode_git_path(change.path[0]))
96
98
                continue
97
99
            try:
98
100
                entry_kls = entry_factory[change.kind[1]]
114
116
            elif change.kind[1] == "symlink":
115
117
                symlink_target = workingtree.get_symlink_target(change.path[1])
116
118
                blob = Blob()
117
 
                blob.data = symlink_target.encode("utf-8")
 
119
                blob.data = encode_git_path(symlink_target)
118
120
                self.store.add_object(blob)
119
121
                sha = blob.id
120
122
                entry.symlink_target = symlink_target
128
130
                raise AssertionError("Unknown kind %r" % change.kind[1])
129
131
            mode = object_mode(change.kind[1], change.executable[1])
130
132
            self._inv_delta.append((change.path[0], change.path[1], change.file_id, entry))
131
 
            encoded_new_path = change.path[1].encode("utf-8")
132
 
            self._blobs[encoded_new_path] = (mode, sha)
 
133
            if change.path[0] is not None:
 
134
                self._deleted_paths.add(encode_git_path(change.path[0]))
 
135
            self._blobs[encode_git_path(change.path[1])] = (mode, sha)
133
136
            if st is not None:
134
137
                yield change.path[1], (entry.text_sha1, st)
135
138
        if not seen_root and len(self.parents) == 0:
146
149
        for entry in basis_tree._iter_tree_contents(include_trees=False):
147
150
            if entry.path in self._blobs:
148
151
                continue
 
152
            if entry.path in self._deleted_paths:
 
153
                continue
149
154
            self._blobs[entry.path] = (entry.mode, entry.sha)
150
155
        self.new_inventory = None
151
156
 
155
160
 
156
161
    def finish_inventory(self):
157
162
        # eliminate blobs that were removed
158
 
        self._blobs = {k: v for (k, v) in viewitems(
159
 
            self._blobs) if v is not None}
 
163
        self._blobs = {k: v for (k, v) in viewitems(self._blobs)}
160
164
 
161
165
    def _iterblobs(self):
162
166
        return ((path, sha, mode) for (path, (mode, sha))