/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: 2019-06-15 17:53:40 UTC
  • mfrom: (7322.1.8 objects-1)
  • Revision ID: breezy.the.bot@gmail.com-20190615175340-yxo036zu96wh8lcz
Use the new attributes on TreeChange rather than indexing.

Merged from https://code.launchpad.net/~jelmer/brz/objects-1/+merge/368859

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
 
89
89
    def record_iter_changes(self, workingtree, basis_revid, iter_changes):
90
90
        seen_root = False
91
 
        for (file_id, path, changed_content, versioned, parent, name, kind,
92
 
             executable) in iter_changes:
93
 
            if kind[1] in ("directory",):
 
91
        for change in iter_changes:
 
92
            if change.kind[1] in ("directory",):
94
93
                self._inv_delta.append(
95
 
                    (path[0], path[1], file_id, entry_factory[kind[1]](
96
 
                        file_id, name[1], parent[1])))
97
 
                if kind[0] in ("file", "symlink"):
98
 
                    self._blobs[path[0].encode("utf-8")] = None
 
94
                    (change.path[0], change.path[1], change.file_id,
 
95
                     entry_factory[change.kind[1]](
 
96
                         change.file_id, change.name[1], change.parent_id[1])))
 
97
                if change.kind[0] in ("file", "symlink"):
 
98
                    self._blobs[change.path[0].encode("utf-8")] = None
99
99
                    self._any_changes = True
100
 
                if path[1] == "":
 
100
                if change.path[1] == "":
101
101
                    seen_root = True
102
102
                continue
103
103
            self._any_changes = True
104
 
            if path[1] is None:
105
 
                self._inv_delta.append((path[0], path[1], file_id, None))
106
 
                self._blobs[path[0].encode("utf-8")] = None
 
104
            if change.path[1] is None:
 
105
                self._inv_delta.append((change.path[0], change.path[1], change.file_id, None))
 
106
                self._blobs[change.path[0].encode("utf-8")] = None
107
107
                continue
108
108
            try:
109
 
                entry_kls = entry_factory[kind[1]]
 
109
                entry_kls = entry_factory[change.kind[1]]
110
110
            except KeyError:
111
 
                raise KeyError("unknown kind %s" % kind[1])
112
 
            entry = entry_kls(file_id, name[1], parent[1])
113
 
            if kind[1] == "file":
114
 
                entry.executable = executable[1]
 
111
                raise KeyError("unknown kind %s" % change.kind[1])
 
112
            entry = entry_kls(change.file_id, change.name[1], change.parent_id[1])
 
113
            if change.kind[1] == "file":
 
114
                entry.executable = change.executable[1]
115
115
                blob = Blob()
116
 
                f, st = workingtree.get_file_with_stat(path[1])
 
116
                f, st = workingtree.get_file_with_stat(change.path[1])
117
117
                try:
118
118
                    blob.data = f.read()
119
119
                finally:
122
122
                entry.text_sha1 = osutils.sha_string(blob.data)
123
123
                self.store.add_object(blob)
124
124
                sha = blob.id
125
 
            elif kind[1] == "symlink":
126
 
                symlink_target = workingtree.get_symlink_target(path[1])
 
125
            elif change.kind[1] == "symlink":
 
126
                symlink_target = workingtree.get_symlink_target(change.path[1])
127
127
                blob = Blob()
128
128
                blob.data = symlink_target.encode("utf-8")
129
129
                self.store.add_object(blob)
130
130
                sha = blob.id
131
131
                entry.symlink_target = symlink_target
132
132
                st = None
133
 
            elif kind[1] == "tree-reference":
134
 
                sha = read_submodule_head(workingtree.abspath(path[1]))
135
 
                reference_revision = workingtree.get_reference_revision(path[1])
 
133
            elif change.kind[1] == "tree-reference":
 
134
                sha = read_submodule_head(workingtree.abspath(change.path[1]))
 
135
                reference_revision = workingtree.get_reference_revision(change.path[1])
136
136
                entry.reference_revision = reference_revision
137
137
                st = None
138
138
            else:
139
 
                raise AssertionError("Unknown kind %r" % kind[1])
140
 
            mode = object_mode(kind[1], executable[1])
141
 
            self._inv_delta.append((path[0], path[1], file_id, entry))
142
 
            encoded_new_path = path[1].encode("utf-8")
 
139
                raise AssertionError("Unknown kind %r" % change.kind[1])
 
140
            mode = object_mode(change.kind[1], change.executable[1])
 
141
            self._inv_delta.append((change.path[0], change.path[1], change.file_id, entry))
 
142
            encoded_new_path = change.path[1].encode("utf-8")
143
143
            self._blobs[encoded_new_path] = (mode, sha)
144
144
            if st is not None:
145
 
                yield path[1], (entry.text_sha1, st)
146
 
            if self._mapping.generate_file_id(encoded_new_path) != file_id:
147
 
                self._override_fileids[encoded_new_path] = file_id
 
145
                yield change.path[1], (entry.text_sha1, st)
 
146
            if self._mapping.generate_file_id(encoded_new_path) != change.file_id:
 
147
                self._override_fileids[encoded_new_path] = change.file_id
148
148
            else:
149
149
                self._override_fileids[encoded_new_path] = None
150
150
        if not seen_root and len(self.parents) == 0: