/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Support for committing in native Git working trees."""
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
20
from dulwich.index import (
23
21
    commit_tree,
24
22
    )
39
37
from ..repository import (
40
38
    CommitBuilder,
41
39
    )
42
 
from ..sixish import (
43
 
    viewitems,
44
 
    )
45
40
 
46
41
from dulwich.objects import (
47
42
    Blob,
51
46
 
52
47
 
53
48
from .mapping import (
 
49
    encode_git_path,
54
50
    object_mode,
55
51
    fix_person_identifier,
56
52
    )
69
65
        self.store = self.repository._git.object_store
70
66
        self._blobs = {}
71
67
        self._inv_delta = []
 
68
        self._deleted_paths = set()
72
69
        self._any_changes = False
73
70
        self._mapping = self.repository.get_mapping()
74
71
 
84
81
                     entry_factory[change.kind[1]](
85
82
                         change.file_id, change.name[1], change.parent_id[1])))
86
83
                if change.kind[0] in ("file", "symlink"):
87
 
                    self._blobs[change.path[0].encode("utf-8")] = None
 
84
                    self._blobs[encode_git_path(change.path[0])] = None
88
85
                    self._any_changes = True
89
86
                if change.path[1] == "":
90
87
                    seen_root = True
92
89
            self._any_changes = True
93
90
            if change.path[1] is None:
94
91
                self._inv_delta.append((change.path[0], change.path[1], change.file_id, None))
95
 
                self._blobs[change.path[0].encode("utf-8")] = None
 
92
                self._deleted_paths.add(encode_git_path(change.path[0]))
96
93
                continue
97
94
            try:
98
95
                entry_kls = entry_factory[change.kind[1]]
114
111
            elif change.kind[1] == "symlink":
115
112
                symlink_target = workingtree.get_symlink_target(change.path[1])
116
113
                blob = Blob()
117
 
                blob.data = symlink_target.encode("utf-8")
 
114
                blob.data = encode_git_path(symlink_target)
118
115
                self.store.add_object(blob)
119
116
                sha = blob.id
120
117
                entry.symlink_target = symlink_target
128
125
                raise AssertionError("Unknown kind %r" % change.kind[1])
129
126
            mode = object_mode(change.kind[1], change.executable[1])
130
127
            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)
 
128
            if change.path[0] is not None:
 
129
                self._deleted_paths.add(encode_git_path(change.path[0]))
 
130
            self._blobs[encode_git_path(change.path[1])] = (mode, sha)
133
131
            if st is not None:
134
132
                yield change.path[1], (entry.text_sha1, st)
135
133
        if not seen_root and len(self.parents) == 0:
146
144
        for entry in basis_tree._iter_tree_contents(include_trees=False):
147
145
            if entry.path in self._blobs:
148
146
                continue
 
147
            if entry.path in self._deleted_paths:
 
148
                continue
149
149
            self._blobs[entry.path] = (entry.mode, entry.sha)
150
150
        self.new_inventory = None
151
151
 
155
155
 
156
156
    def finish_inventory(self):
157
157
        # eliminate blobs that were removed
158
 
        self._blobs = {k: v for (k, v) in viewitems(
159
 
            self._blobs) if v is not None}
 
158
        self._blobs = {k: v for (k, v) in self._blobs.items()}
160
159
 
161
160
    def _iterblobs(self):
162
161
        return ((path, sha, mode) for (path, (mode, sha))
163
 
                in viewitems(self._blobs))
 
162
                in self._blobs.items())
164
163
 
165
164
    def commit(self, message):
166
165
        self._validate_unicode_text(message, 'commit message')