Merge lp:~jelmer/brz-git/track-store into lp:brz-git

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 1906
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz-git/track-store
Merge into: lp:brz-git
Diff against target: 213 lines (+35/-33)
1 file modified
tree.py (+35/-33)
To merge this branch: bzr merge lp:~jelmer/brz-git/track-store
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+342360@code.launchpad.net

Commit message

Track store in GitRevisionTree.

Description of the change

Track store in GitRevisionTree.

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 'tree.py'
2--- tree.py 2018-03-27 03:09:48 +0000
3+++ tree.py 2018-03-28 23:03:20 +0000
4@@ -265,16 +265,16 @@
5
6 def all_versioned_paths(self):
7 ret = set()
8- todo = set([('', self.tree)])
9+ todo = set([(store, '', self.tree)])
10 while todo:
11- (path, tree_id) = todo.pop()
12+ (store, path, tree_id) = todo.pop()
13 if tree_id is None:
14 continue
15- tree = self.store[tree_id]
16+ tree = store[tree_id]
17 for name, mode, hexsha in tree.items():
18 subpath = posixpath.join(path, name)
19 if stat.S_ISDIR(mode):
20- todo.add((subpath, hexsha))
21+ todo.add((store, subpath, hexsha))
22 else:
23 ret.add(subpath)
24 return ret
25@@ -302,20 +302,22 @@
26 if self.tree is None:
27 raise errors.NoSuchFile(path)
28 try:
29- return tree_lookup_path(self.store.__getitem__, self.tree,
30+ (mode, hexsha) = tree_lookup_path(self.store.__getitem__, self.tree,
31 path.encode('utf-8'))
32 except KeyError:
33 raise errors.NoSuchFile(self, path)
34+ else:
35+ return (self.store, mode, hexsha)
36
37 def is_executable(self, path, file_id=None):
38- (mode, hexsha) = self._lookup_path(path)
39+ (store, mode, hexsha) = self._lookup_path(path)
40 if mode is None:
41 # the tree root is a directory
42 return False
43 return mode_is_executable(mode)
44
45 def kind(self, path, file_id=None):
46- (mode, hexsha) = self._lookup_path(path)
47+ (store, mode, hexsha) = self._lookup_path(path)
48 if mode is None:
49 # the tree root is a directory
50 return "directory"
51@@ -334,7 +336,7 @@
52 return
53 if from_dir is None:
54 from_dir = u""
55- (mode, hexsha) = self._lookup_path(from_dir)
56+ (store, mode, hexsha) = self._lookup_path(from_dir)
57 if mode is None: # Root
58 root_ie = self._get_dir_ie(b"", None)
59 else:
60@@ -343,16 +345,16 @@
61 if mode_kind(mode) == 'directory':
62 root_ie = self._get_dir_ie(from_dir.encode("utf-8"), parent_id)
63 else:
64- root_ie = self._get_file_ie(from_dir.encode("utf-8"),
65+ root_ie = self._get_file_ie(store, from_dir.encode("utf-8"),
66 posixpath.basename(from_dir), mode, hexsha)
67 if from_dir != "" or include_root:
68 yield (from_dir, "V", root_ie.kind, root_ie.file_id, root_ie)
69 todo = set()
70 if root_ie.kind == 'directory':
71- todo.add((from_dir.encode("utf-8"), hexsha, root_ie.file_id))
72+ todo.add((store, from_dir.encode("utf-8"), hexsha, root_ie.file_id))
73 while todo:
74- (path, hexsha, parent_id) = todo.pop()
75- tree = self.store[hexsha]
76+ (store, path, hexsha, parent_id) = todo.pop()
77+ tree = store[hexsha]
78 for name, mode, hexsha in tree.iteritems():
79 if self.mapping.is_special_file(name):
80 continue
81@@ -360,12 +362,12 @@
82 if stat.S_ISDIR(mode):
83 ie = self._get_dir_ie(child_path, parent_id)
84 if recursive:
85- todo.add((child_path, hexsha, ie.file_id))
86+ todo.add((store, child_path, hexsha, ie.file_id))
87 else:
88- ie = self._get_file_ie(child_path, name, mode, hexsha, parent_id)
89+ ie = self._get_file_ie(store, child_path, name, mode, hexsha, parent_id)
90 yield child_path.decode('utf-8'), "V", ie.kind, ie.file_id, ie
91
92- def _get_file_ie(self, path, name, mode, hexsha, parent_id):
93+ def _get_file_ie(self, store, path, name, mode, hexsha, parent_id):
94 if type(path) is not bytes:
95 raise TypeError(path)
96 if type(name) is not bytes:
97@@ -374,11 +376,11 @@
98 file_id = self._fileid_map.lookup_file_id(path)
99 ie = entry_factory[kind](file_id, name.decode("utf-8"), parent_id)
100 if kind == 'symlink':
101- ie.symlink_target = self.store[hexsha].data.decode('utf-8')
102+ ie.symlink_target = store[hexsha].data.decode('utf-8')
103 elif kind == 'tree-reference':
104 ie.reference_revision = self.mapping.revision_id_foreign_to_bzr(hexsha)
105 else:
106- data = self.store[hexsha].data
107+ data = store[hexsha].data
108 ie.text_sha1 = osutils.sha_string(data)
109 ie.text_size = len(data)
110 ie.executable = mode_is_executable(mode)
111@@ -390,14 +392,14 @@
112 posixpath.basename(path).decode("utf-8"), parent_id)
113
114 def iter_child_entries(self, path, file_id=None):
115- (mode, tree_sha) = self._lookup_path(path)
116+ (store, mode, tree_sha) = self._lookup_path(path)
117
118 if not stat.S_ISDIR(mode):
119 return
120
121 encoded_path = path.encode('utf-8')
122 file_id = self.path2id(path)
123- tree = self.store[tree_sha]
124+ tree = store[tree_sha]
125 for name, mode, hexsha in tree.iteritems():
126 if self.mapping.is_special_file(name):
127 continue
128@@ -405,7 +407,7 @@
129 if stat.S_ISDIR(mode):
130 yield self._get_dir_ie(child_path, file_id)
131 else:
132- yield self._get_file_ie(child_path, name, mode, hexsha,
133+ yield self._get_file_ie(store, child_path, name, mode, hexsha,
134 file_id)
135
136 def iter_entries_by_dir(self, specific_files=None, yield_parents=False):
137@@ -419,13 +421,13 @@
138 specific_files = None
139 else:
140 specific_files = set([p.encode('utf-8') for p in specific_files])
141- todo = set([("", self.tree, None)])
142+ todo = set([(self.store, "", self.tree, None)])
143 while todo:
144- path, tree_sha, parent_id = todo.pop()
145+ store, path, tree_sha, parent_id = todo.pop()
146 ie = self._get_dir_ie(path, parent_id)
147 if specific_files is None or path in specific_files:
148 yield path.decode("utf-8"), ie
149- tree = self.store[tree_sha]
150+ tree = store[tree_sha]
151 for name, mode, hexsha in tree.iteritems():
152 if self.mapping.is_special_file(name):
153 continue
154@@ -433,10 +435,10 @@
155 if stat.S_ISDIR(mode):
156 if (specific_files is None or
157 any(filter(lambda p: p.startswith(child_path), specific_files))):
158- todo.add((child_path, hexsha, ie.file_id))
159+ todo.add((store, child_path, hexsha, ie.file_id))
160 elif specific_files is None or child_path in specific_files:
161 yield (child_path.decode("utf-8"),
162- self._get_file_ie(child_path, name, mode, hexsha,
163+ self._get_file_ie(store, child_path, name, mode, hexsha,
164 ie.file_id))
165
166 def get_revision_id(self):
167@@ -449,22 +451,22 @@
168 return osutils.sha_string(self.get_file_text(path, file_id))
169
170 def get_file_verifier(self, path, file_id=None, stat_value=None):
171- (mode, hexsha) = self._lookup_path(path)
172+ (store, mode, hexsha) = self._lookup_path(path)
173 return ("GIT", hexsha)
174
175 def get_file_text(self, path, file_id=None):
176 """See RevisionTree.get_file_text."""
177- (mode, hexsha) = self._lookup_path(path)
178+ (store, mode, hexsha) = self._lookup_path(path)
179 if stat.S_ISREG(mode):
180- return self.store[hexsha].data
181+ return store[hexsha].data
182 else:
183 return b""
184
185 def get_symlink_target(self, path, file_id=None):
186 """See RevisionTree.get_symlink_target."""
187- (mode, hexsha) = self._lookup_path(path)
188+ (store, mode, hexsha) = self._lookup_path(path)
189 if stat.S_ISLNK(mode):
190- return self.store[hexsha].data.decode('utf-8')
191+ return store[hexsha].data.decode('utf-8')
192 else:
193 return None
194
195@@ -476,16 +478,16 @@
196 def path_content_summary(self, path):
197 """See Tree.path_content_summary."""
198 try:
199- (mode, hexsha) = self._lookup_path(path)
200+ (store, mode, hexsha) = self._lookup_path(path)
201 except errors.NoSuchFile:
202 return ('missing', None, None, None)
203 kind = mode_kind(mode)
204 if kind == 'file':
205 executable = mode_is_executable(mode)
206- contents = self.store[hexsha].data
207+ contents = store[hexsha].data
208 return (kind, len(contents), executable, osutils.sha_string(contents))
209 elif kind == 'symlink':
210- return (kind, None, None, self.store[hexsha].data)
211+ return (kind, None, None, store[hexsha].data)
212 else:
213 return (kind, None, None, None)
214

Subscribers

People subscribed via source and target branches

to all changes: