/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-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.versioned[0] and not change.copied:
 
79
                file_id = self._mapping.generate_file_id(change.path[0])
 
80
            elif change.versioned[1]:
 
81
                file_id = self._mapping.generate_file_id(change.path[1])
 
82
            else:
 
83
                file_id = None
 
84
            if change.path[1]:
 
85
                parent_id_new = self._mapping.generate_file_id(osutils.dirname(change.path[1]))
 
86
            else:
 
87
                parent_id_new = None
78
88
            if change.kind[1] in ("directory",):
79
89
                self._inv_delta.append(
80
 
                    (change.path[0], change.path[1], change.file_id,
 
90
                    (change.path[0], change.path[1], file_id,
81
91
                     entry_factory[change.kind[1]](
82
 
                         change.file_id, change.name[1], change.parent_id[1])))
 
92
                         file_id, change.name[1], parent_id_new)))
83
93
                if change.kind[0] in ("file", "symlink"):
84
94
                    self._blobs[encode_git_path(change.path[0])] = None
85
95
                    self._any_changes = True
88
98
                continue
89
99
            self._any_changes = True
90
100
            if change.path[1] is None:
91
 
                self._inv_delta.append((change.path[0], change.path[1], change.file_id, None))
 
101
                self._inv_delta.append((change.path[0], change.path[1], file_id, None))
92
102
                self._deleted_paths.add(encode_git_path(change.path[0]))
93
103
                continue
94
104
            try:
95
105
                entry_kls = entry_factory[change.kind[1]]
96
106
            except KeyError:
97
107
                raise KeyError("unknown kind %s" % change.kind[1])
98
 
            entry = entry_kls(change.file_id, change.name[1], change.parent_id[1])
 
108
            entry = entry_kls(file_id, change.name[1], parent_id_new)
99
109
            if change.kind[1] == "file":
100
110
                entry.executable = change.executable[1]
101
111
                blob = Blob()
104
114
                    blob.data = f.read()
105
115
                finally:
106
116
                    f.close()
107
 
                entry.text_size = len(blob.data)
108
 
                entry.text_sha1 = osutils.sha_string(blob.data)
 
117
                sha = blob.id
 
118
                entry.text_size = st.st_size
 
119
                entry.git_sha1 = sha
109
120
                self.store.add_object(blob)
110
 
                sha = blob.id
111
121
            elif change.kind[1] == "symlink":
112
122
                symlink_target = workingtree.get_symlink_target(change.path[1])
113
123
                blob = Blob()
124
134
            else:
125
135
                raise AssertionError("Unknown kind %r" % change.kind[1])
126
136
            mode = object_mode(change.kind[1], change.executable[1])
127
 
            self._inv_delta.append((change.path[0], change.path[1], change.file_id, entry))
 
137
            self._inv_delta.append((change.path[0], change.path[1], file_id, entry))
128
138
            if change.path[0] is not None:
129
139
                self._deleted_paths.add(encode_git_path(change.path[0]))
130
140
            self._blobs[encode_git_path(change.path[1])] = (mode, sha)
131
141
            if st is not None:
132
 
                yield change.path[1], (entry.text_sha1, st)
 
142
                yield change.path[1], (entry.git_sha1, st)
133
143
        if not seen_root and len(self.parents) == 0:
134
144
            raise RootMissing()
135
145
        if getattr(workingtree, "basis_tree", False):