Merge lp:~jelmer/brz-git/content-sha into lp:brz-git

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 1839
Merge reported by: The Breezy Bot
Merged at revision: 1839
Proposed branch: lp:~jelmer/brz-git/content-sha
Merge into: lp:brz-git
Diff against target: 73 lines (+16/-15)
1 file modified
commit.py (+16/-15)
To merge this branch: bzr merge lp:~jelmer/brz-git/content-sha
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+341189@code.launchpad.net

Commit message

Only yield text contents, not symlinks.

Description of the change

Only yield text contents, not symlinks.

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-08 01:08:54 +0000
3+++ commit.py 2018-03-09 03:29:30 +0000
4@@ -111,7 +111,11 @@
5 if kind[1] == "file":
6 entry.executable = executable[1]
7 blob = Blob()
8- blob.data = workingtree.get_file_text(path[1], file_id)
9+ f, st = workingtree.get_file_with_stat(path[1], file_id)
10+ try:
11+ blob.data = f.read()
12+ finally:
13+ f.close()
14 entry.text_size = len(blob.data)
15 entry.text_sha1 = osutils.sha_string(blob.data)
16 self.store.add_object(blob)
17@@ -123,24 +127,20 @@
18 self.store.add_object(blob)
19 sha = blob.id
20 entry.symlink_target = symlink_target
21+ st = None
22 elif kind[1] == "tree-reference":
23 sha = treeref_sha1(path[1], file_id)
24 reference_revision = workingtree.get_reference_revision(path[1], file_id)
25 entry.reference_revision = reference_revision
26+ st = None
27 else:
28 raise AssertionError("Unknown kind %r" % kind[1])
29 mode = object_mode(kind[1], executable[1])
30 self._inv_delta.append((path[0], path[1], file_id, entry))
31 encoded_new_path = path[1].encode("utf-8")
32 self._blobs[encoded_new_path] = (mode, sha)
33- file_sha1 = workingtree.get_file_sha1(path[1], file_id)
34- if file_sha1 is None:
35- # File no longer exists
36- if path[0] is not None:
37- self._blobs[path[0].encode("utf-8")] = None
38- continue
39- _, st = workingtree.get_file_with_stat(path[1], file_id)
40- yield file_id, path[1], (file_sha1, st)
41+ if st is not None:
42+ yield file_id, path[1], (entry.text_sha1, st)
43 if self._mapping.generate_file_id(encoded_new_path) != file_id:
44 self._override_fileids[encoded_new_path] = file_id
45 else:
46@@ -158,20 +158,21 @@
47 # Fill in entries that were not changed
48 for path, entry in basis_tree.iter_entries_by_dir():
49 assert isinstance(path, unicode)
50- if entry.kind not in ("file", "symlink", "tree-reference"):
51+ if entry.kind == 'directory':
52 continue
53- if not path in self._blobs:
54+ encoded_path = path.encode('utf-8')
55+ if encoded_path not in self._blobs:
56 if entry.kind == "symlink":
57 blob = Blob()
58 blob.data = basis_tree.get_symlink_target(path, entry.file_id).encode('utf-8')
59- self._blobs[path.encode("utf-8")] = (entry_mode(entry), blob.id)
60+ self._blobs[encoded_path] = (entry_mode(entry), blob.id)
61 elif entry.kind == "file":
62 blob = Blob()
63 blob.data = basis_tree.get_file_text(path, entry.file_id)
64- self._blobs[path.encode("utf-8")] = (entry_mode(entry), blob.id)
65+ self._blobs[encoded_path] = (entry_mode(entry), blob.id)
66 else:
67- (mode, sha) = workingtree._lookup_entry(path.encode("utf-8"), update_index=True)
68- self._blobs[path.encode("utf-8")] = (mode, sha)
69+ (mode, sha) = workingtree._lookup_entry(encoded_path, update_index=True)
70+ self._blobs[encoded_path] = (mode, sha)
71 if not self._lossy:
72 try:
73 fileid_map = dict(basis_tree._fileid_map.file_ids)

Subscribers

People subscribed via source and target branches

to all changes: