Merge lp:~jelmer/brz-git/efficient-commit into lp:brz-git

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 1896
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz-git/efficient-commit
Merge into: lp:brz-git
Diff against target: 47 lines (+9/-16)
2 files modified
commit.py (+3/-16)
tree.py (+6/-0)
To merge this branch: bzr merge lp:~jelmer/brz-git/efficient-commit
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+342165@code.launchpad.net

Commit message

Avoid expensive conversion APIs in commit.

Description of the change

Avoid expensive conversion APIs in commit.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Rubberstamp! Proposer approves of own proposal.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'commit.py'
2--- commit.py 2018-03-24 10:17:52 +0000
3+++ commit.py 2018-03-27 01:47:03 +0000
4@@ -156,23 +156,10 @@
5 basis_revid = self.parents[0]
6 basis_tree = self.repository.revision_tree(basis_revid)
7 # Fill in entries that were not changed
8- for path, entry in basis_tree.iter_entries_by_dir():
9- if type(path) is not unicode:
10- raise TypeError(path)
11- if entry.kind == 'directory':
12+ for entry in basis_tree._iter_tree_contents(include_trees=False):
13+ if entry.path in self._blobs:
14 continue
15- encoded_path = path.encode('utf-8')
16- if encoded_path not in self._blobs:
17- if entry.kind == "symlink":
18- blob = Blob()
19- blob.data = basis_tree.get_symlink_target(path, entry.file_id).encode('utf-8')
20- self._blobs[encoded_path] = (entry_mode(entry), blob.id)
21- elif entry.kind == "file":
22- blob = Blob()
23- blob.data = basis_tree.get_file_text(path, entry.file_id)
24- self._blobs[encoded_path] = (entry_mode(entry), blob.id)
25- else:
26- raise NotImplementedError
27+ self._blobs[entry.path] = (entry.mode, entry.sha)
28 if not self._lossy:
29 try:
30 fileid_map = dict(basis_tree._fileid_map.file_ids)
31
32=== modified file 'tree.py'
33--- tree.py 2018-03-26 00:32:23 +0000
34+++ tree.py 2018-03-27 01:47:03 +0000
35@@ -506,6 +506,12 @@
36 raise errors.PathsNotVersionedError(unversioned)
37 return filter(self.is_versioned, paths)
38
39+ def _iter_tree_contents(self, include_trees=False):
40+ if self.tree is None:
41+ return iter([])
42+ return self.store.iter_tree_contents(
43+ self.tree, include_trees=include_trees)
44+
45
46 def tree_delta_from_git_changes(changes, mapping,
47 (old_fileid_map, new_fileid_map), specific_files=None,

Subscribers

People subscribed via source and target branches

to all changes: