/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-08-23 01:15:41 UTC
  • mfrom: (7520.1.4 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200823011541-nv0oh7nzaganx2qy
Merge lp:brz/3.1.

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

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