/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-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

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