Merge lp:~jelmer/loggerhead/no-file-ids into lp:loggerhead
- no-file-ids
- Merge into trunk-rich
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 523 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | lp:~jelmer/loggerhead/no-file-ids |
Merge into: | lp:loggerhead |
Diff against target: |
705 lines (+102/-175) 15 files modified
loggerhead/controllers/annotate_ui.py (+3/-7) loggerhead/controllers/changelog_ui.py (+5/-10) loggerhead/controllers/download_ui.py (+1/-6) loggerhead/controllers/inventory_ui.py (+7/-15) loggerhead/controllers/revision_ui.py (+5/-5) loggerhead/controllers/view_ui.py (+3/-13) loggerhead/history.py (+51/-73) loggerhead/templates/changelog.pt (+1/-1) loggerhead/templates/inventory.pt (+3/-3) loggerhead/templates/search-box.pt (+1/-2) loggerhead/templates/view.pt (+1/-1) loggerhead/tests/fixtures.py (+2/-3) loggerhead/tests/test_controllers.py (+13/-25) loggerhead/tests/test_simple.py (+3/-6) loggerhead/util.py (+3/-5) |
To merge this branch: | bzr merge lp:~jelmer/loggerhead/no-file-ids |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson (community) | Approve | ||
Review via email: mp+426375@code.launchpad.net |
Commit message
Avoid use of file ids - use paths instead.
Description of the change
Avoid use of file ids - use paths instead.
This prepares loggerhead for upcoming Breezy changes, which remove file ids
from the primary API. The goal behind this is to make the implementation
of non-Bazaar filesystems simpler.
To post a comment you must log in.
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote : | # |
A commit message must be set
https:/
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote : | # |
Running landing tests failed
https:/
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'loggerhead/controllers/annotate_ui.py' | |||
2 | --- loggerhead/controllers/annotate_ui.py 2020-07-14 16:41:12 +0000 | |||
3 | +++ loggerhead/controllers/annotate_ui.py 2022-07-06 12:59:30 +0000 | |||
4 | @@ -24,14 +24,10 @@ | |||
5 | 24 | 24 | ||
6 | 25 | class AnnotateUI(ViewUI): | 25 | class AnnotateUI(ViewUI): |
7 | 26 | 26 | ||
10 | 27 | def annotate_file(self, info): | 27 | def annotate_file(self, path, info): |
9 | 28 | file_id = info['file_id'] | ||
11 | 29 | revid = info['change'].revid | 28 | revid = info['change'].revid |
12 | 30 | if not isinstance(file_id, bytes): | ||
13 | 31 | raise TypeError(file_id) | ||
14 | 32 | if not isinstance(revid, bytes): | 29 | if not isinstance(revid, bytes): |
15 | 33 | raise TypeError(revid) | 30 | raise TypeError(revid) |
16 | 34 | path = self._history.get_path(revid, file_id) | ||
17 | 35 | 31 | ||
18 | 36 | tree = self.tree_for(path, revid) | 32 | tree = self.tree_for(path, revid) |
19 | 37 | 33 | ||
20 | @@ -43,7 +39,7 @@ | |||
21 | 43 | revisions = {} | 39 | revisions = {} |
22 | 44 | 40 | ||
23 | 45 | lineno = 0 | 41 | lineno = 0 |
25 | 46 | for (line_revid, text), lineno in zip(tree.annotate_iter(path, file_id), itertools.count(1)): | 42 | for (line_revid, text), lineno in zip(tree.annotate_iter(path), itertools.count(1)): |
26 | 47 | if line_revid != last_line_revid: | 43 | if line_revid != last_line_revid: |
27 | 48 | last_line_revid = line_revid | 44 | last_line_revid = line_revid |
28 | 49 | 45 | ||
29 | @@ -84,6 +80,6 @@ | |||
30 | 84 | 80 | ||
31 | 85 | def get_values(self, path, kwargs, headers): | 81 | def get_values(self, path, kwargs, headers): |
32 | 86 | values = super(AnnotateUI, self).get_values(path, kwargs, headers) | 82 | values = super(AnnotateUI, self).get_values(path, kwargs, headers) |
34 | 87 | values['annotated'] = self.annotate_file(values) | 83 | values['annotated'] = self.annotate_file(path, values) |
35 | 88 | 84 | ||
36 | 89 | return values | 85 | return values |
37 | 90 | 86 | ||
38 | === modified file 'loggerhead/controllers/changelog_ui.py' | |||
39 | --- loggerhead/controllers/changelog_ui.py 2020-07-08 17:14:19 +0000 | |||
40 | +++ loggerhead/controllers/changelog_ui.py 2022-07-06 12:59:30 +0000 | |||
41 | @@ -35,21 +35,16 @@ | |||
42 | 35 | def get_values(self, path, kwargs, headers): | 35 | def get_values(self, path, kwargs, headers): |
43 | 36 | history = self._history | 36 | history = self._history |
44 | 37 | revid = self.get_revid() | 37 | revid = self.get_revid() |
48 | 38 | filter_file_id = kwargs.get('filter_file_id', None) | 38 | filter_path = kwargs.get('filter_path', path) |
46 | 39 | if filter_file_id is not None: | ||
47 | 40 | filter_file_id = urlutils.unquote_to_bytes(osutils.safe_utf8(filter_file_id)) | ||
49 | 41 | query = kwargs.get('q', None) | 39 | query = kwargs.get('q', None) |
50 | 42 | start_revid = history.fix_revid(kwargs.get('start_revid', None)) | 40 | start_revid = history.fix_revid(kwargs.get('start_revid', None)) |
51 | 43 | orig_start_revid = start_revid | 41 | orig_start_revid = start_revid |
53 | 44 | pagesize = 20#int(config.get('pagesize', '20')) | 42 | pagesize = 20 #int(config.get('pagesize', '20')) |
54 | 45 | search_failed = False | 43 | search_failed = False |
55 | 46 | 44 | ||
56 | 47 | if filter_file_id is None and path is not None: | ||
57 | 48 | filter_file_id = history.get_file_id(revid, path) | ||
58 | 49 | |||
59 | 50 | try: | 45 | try: |
60 | 51 | revid, start_revid, revid_list = history.get_view( | 46 | revid, start_revid, revid_list = history.get_view( |
62 | 52 | revid, start_revid, filter_file_id, query, | 47 | revid, start_revid, filter_path, query, |
63 | 53 | extra_rev_count=pagesize+1) | 48 | extra_rev_count=pagesize+1) |
64 | 54 | util.set_context(kwargs) | 49 | util.set_context(kwargs) |
65 | 55 | 50 | ||
66 | @@ -76,7 +71,7 @@ | |||
67 | 76 | 71 | ||
68 | 77 | navigation = util.Container( | 72 | navigation = util.Container( |
69 | 78 | pagesize=pagesize, revid=revid, start_revid=start_revid, | 73 | pagesize=pagesize, revid=revid, start_revid=start_revid, |
71 | 79 | revid_list=revid_list, filter_file_id=filter_file_id, | 74 | revid_list=revid_list, filter_path=filter_path, |
72 | 80 | scan_url='/changes', branch=self._branch, feed=True, history=history) | 75 | scan_url='/changes', branch=self._branch, feed=True, history=history) |
73 | 81 | if query is not None: | 76 | if query is not None: |
74 | 82 | navigation.query = query | 77 | navigation.query = query |
75 | @@ -104,7 +99,7 @@ | |||
76 | 104 | 'history': history, | 99 | 'history': history, |
77 | 105 | 'revid': revid, | 100 | 'revid': revid, |
78 | 106 | 'navigation': navigation, | 101 | 'navigation': navigation, |
80 | 107 | 'filter_file_id': filter_file_id, | 102 | 'filter_path': filter_path, |
81 | 108 | 'start_revid': start_revid, | 103 | 'start_revid': start_revid, |
82 | 109 | 'viewing_from': (orig_start_revid is not None) and | 104 | 'viewing_from': (orig_start_revid is not None) and |
83 | 110 | (orig_start_revid != history.last_revid), | 105 | (orig_start_revid != history.last_revid), |
84 | 111 | 106 | ||
85 | === modified file 'loggerhead/controllers/download_ui.py' | |||
86 | --- loggerhead/controllers/download_ui.py 2020-07-08 17:12:21 +0000 | |||
87 | +++ loggerhead/controllers/download_ui.py 2022-07-06 12:59:30 +0000 | |||
88 | @@ -61,12 +61,7 @@ | |||
89 | 61 | try: | 61 | try: |
90 | 62 | path, filename, content = h.get_file(args[1], revid) | 62 | path, filename, content = h.get_file(args[1], revid) |
91 | 63 | except (NoSuchFile, NoSuchRevision): | 63 | except (NoSuchFile, NoSuchRevision): |
98 | 64 | # Compatibility API for /download/rev_id/file_id/<filename> | 64 | raise httpexceptions.HTTPNotFound() |
93 | 65 | try: | ||
94 | 66 | path, filename, content = h.get_file_by_fileid( | ||
95 | 67 | args[1].encode('UTF-8'), revid) | ||
96 | 68 | except (NoSuchId, NoSuchRevision): | ||
97 | 69 | raise httpexceptions.HTTPNotFound() | ||
99 | 70 | mime_type, encoding = mimetypes.guess_type(filename) | 65 | mime_type, encoding = mimetypes.guess_type(filename) |
100 | 71 | if mime_type is None: | 66 | if mime_type is None: |
101 | 72 | mime_type = 'application/octet-stream' | 67 | mime_type = 'application/octet-stream' |
102 | 73 | 68 | ||
103 | === modified file 'loggerhead/controllers/inventory_ui.py' | |||
104 | --- loggerhead/controllers/inventory_ui.py 2018-11-01 21:48:40 +0000 | |||
105 | +++ loggerhead/controllers/inventory_ui.py 2022-07-06 12:59:30 +0000 | |||
106 | @@ -95,7 +95,7 @@ | |||
107 | 95 | file = util.Container( | 95 | file = util.Container( |
108 | 96 | filename=entry.name, executable=entry.executable, | 96 | filename=entry.name, executable=entry.executable, |
109 | 97 | kind=entry.kind, absolutepath=child_path, | 97 | kind=entry.kind, absolutepath=child_path, |
111 | 98 | file_id=entry.file_id, size=size, revid=child_revision, | 98 | size=size, revid=child_revision, |
112 | 99 | change=change_dict[child_revision], contents_changed_rev=contents_changed_rev) | 99 | change=change_dict[child_revision], contents_changed_rev=contents_changed_rev) |
113 | 100 | file_list.append(file) | 100 | file_list.append(file) |
114 | 101 | 101 | ||
115 | @@ -125,23 +125,15 @@ | |||
116 | 125 | except errors.NoSuchRevision: | 125 | except errors.NoSuchRevision: |
117 | 126 | raise HTTPNotFound() | 126 | raise HTTPNotFound() |
118 | 127 | 127 | ||
119 | 128 | file_id = kwargs.get('file_id', None) | ||
120 | 129 | start_revid = kwargs.get('start_revid', None) | 128 | start_revid = kwargs.get('start_revid', None) |
121 | 130 | sort_type = kwargs.get('sort', 'filename') | 129 | sort_type = kwargs.get('sort', 'filename') |
122 | 131 | 130 | ||
136 | 132 | if path is not None: | 131 | if path is None: |
137 | 133 | path = path.rstrip('/') | 132 | path = "/" |
138 | 134 | file_id = rev_tree.path2id(path) | 133 | |
139 | 135 | if file_id is None: | 134 | path = path.rstrip('/') |
140 | 136 | raise HTTPNotFound() | 135 | if not rev_tree.has_filename(path) and not is_null_rev(revid): |
141 | 137 | else: | 136 | raise HTTPNotFound() |
129 | 138 | if file_id is None: | ||
130 | 139 | path = '' | ||
131 | 140 | else: | ||
132 | 141 | try: | ||
133 | 142 | path = rev_tree.id2path(file_id) | ||
134 | 143 | except errors.NoSuchId: | ||
135 | 144 | raise HTTPNotFound() | ||
142 | 145 | 137 | ||
143 | 146 | # Are we at the top of the tree | 138 | # Are we at the top of the tree |
144 | 147 | if path in ['/', '']: | 139 | if path in ['/', '']: |
145 | 148 | 140 | ||
146 | === modified file 'loggerhead/controllers/revision_ui.py' | |||
147 | --- loggerhead/controllers/revision_ui.py 2021-03-29 11:18:58 +0000 | |||
148 | +++ loggerhead/controllers/revision_ui.py 2022-07-06 12:59:30 +0000 | |||
149 | @@ -46,7 +46,7 @@ | |||
150 | 46 | h = self._history | 46 | h = self._history |
151 | 47 | revid = self.get_revid() | 47 | revid = self.get_revid() |
152 | 48 | 48 | ||
154 | 49 | filter_file_id = kwargs.get('filter_file_id', None) | 49 | filter_path = kwargs.get('filter_path', None) |
155 | 50 | start_revid = h.fix_revid(kwargs.get('start_revid', None)) | 50 | start_revid = h.fix_revid(kwargs.get('start_revid', None)) |
156 | 51 | query = kwargs.get('q', None) | 51 | query = kwargs.get('q', None) |
157 | 52 | compare_revid = h.fix_revid(kwargs.get('compare_revid', None)) | 52 | compare_revid = h.fix_revid(kwargs.get('compare_revid', None)) |
158 | @@ -56,7 +56,7 @@ | |||
159 | 56 | try: | 56 | try: |
160 | 57 | revid, start_revid, revid_list = h.get_view(revid, | 57 | revid, start_revid, revid_list = h.get_view(revid, |
161 | 58 | start_revid, | 58 | start_revid, |
163 | 59 | filter_file_id, | 59 | filter_path, |
164 | 60 | query) | 60 | query) |
165 | 61 | except BaseException: | 61 | except BaseException: |
166 | 62 | self.log.exception('Exception fetching changes') | 62 | self.log.exception('Exception fetching changes') |
167 | @@ -102,12 +102,12 @@ | |||
168 | 102 | super(RevisionUI, self).add_template_values(values) | 102 | super(RevisionUI, self).add_template_values(values) |
169 | 103 | remember = self._history.fix_revid(self.kwargs.get('remember', None)) | 103 | remember = self._history.fix_revid(self.kwargs.get('remember', None)) |
170 | 104 | query = self.kwargs.get('q', None) | 104 | query = self.kwargs.get('q', None) |
172 | 105 | filter_file_id = self.kwargs.get('filter_file_id', None) | 105 | filter_path = self.kwargs.get('filter_path', None) |
173 | 106 | start_revid = self.kwargs['start_revid'] | 106 | start_revid = self.kwargs['start_revid'] |
174 | 107 | navigation = util.Container( | 107 | navigation = util.Container( |
175 | 108 | revid_list=self.revid_list, revid=values['revid'], | 108 | revid_list=self.revid_list, revid=values['revid'], |
176 | 109 | start_revid=start_revid, | 109 | start_revid=start_revid, |
178 | 110 | filter_file_id=filter_file_id, pagesize=1, | 110 | filter_path=filter_path, pagesize=1, |
179 | 111 | scan_url='/revision', branch=self._branch, feed=True, | 111 | scan_url='/revision', branch=self._branch, feed=True, |
180 | 112 | history=self._history) | 112 | history=self._history) |
181 | 113 | if query is not None: | 113 | if query is not None: |
182 | @@ -161,7 +161,7 @@ | |||
183 | 161 | 'navigation': navigation, | 161 | 'navigation': navigation, |
184 | 162 | 'remember': remember, | 162 | 'remember': remember, |
185 | 163 | 'compare_revid': self.compare_revid, | 163 | 'compare_revid': self.compare_revid, |
187 | 164 | 'filter_file_id': filter_file_id, | 164 | 'filter_path': filter_path, |
188 | 165 | 'diff_chunks': diff_chunks, | 165 | 'diff_chunks': diff_chunks, |
189 | 166 | 'query': query, | 166 | 'query': query, |
190 | 167 | 'can_export': can_export, | 167 | 'can_export': can_export, |
191 | 168 | 168 | ||
192 | === modified file 'loggerhead/controllers/view_ui.py' | |||
193 | --- loggerhead/controllers/view_ui.py 2021-11-15 14:40:11 +0000 | |||
194 | +++ loggerhead/controllers/view_ui.py 2022-07-06 12:59:30 +0000 | |||
195 | @@ -99,19 +99,10 @@ | |||
196 | 99 | history = self._history | 99 | history = self._history |
197 | 100 | branch = history._branch | 100 | branch = history._branch |
198 | 101 | revid = self.get_revid() | 101 | revid = self.get_revid() |
205 | 102 | file_id = kwargs.get('file_id', None) | 102 | if path is None: |
206 | 103 | if file_id is not None: | 103 | raise HTTPBadRequest('No filename provided to view') |
201 | 104 | file_id = urlutils.unquote_to_bytes(osutils.safe_utf8(file_id)) | ||
202 | 105 | if (file_id is None) and (path is None): | ||
203 | 106 | raise HTTPBadRequest('No file_id or filename ' | ||
204 | 107 | 'provided to view') | ||
207 | 108 | 104 | ||
214 | 109 | try: | 105 | if not history.file_exists(revid, path): |
209 | 110 | if file_id is None: | ||
210 | 111 | file_id = history.get_file_id(revid, path) | ||
211 | 112 | if path is None: | ||
212 | 113 | path = history.get_path(revid, file_id) | ||
213 | 114 | except (NoSuchId, NoSuchRevision): | ||
215 | 115 | raise HTTPNotFound() | 106 | raise HTTPNotFound() |
216 | 116 | 107 | ||
217 | 117 | filename = os.path.basename(path) | 108 | filename = os.path.basename(path) |
218 | @@ -151,7 +142,6 @@ | |||
219 | 151 | # checking whether we're in "annotated" mode. | 142 | # checking whether we're in "annotated" mode. |
220 | 152 | 'annotated': {}, | 143 | 'annotated': {}, |
221 | 153 | 'revno_url': revno_url, | 144 | 'revno_url': revno_url, |
222 | 154 | 'file_id': file_id, | ||
223 | 155 | 'file_path': path, | 145 | 'file_path': path, |
224 | 156 | 'filename': filename, | 146 | 'filename': filename, |
225 | 157 | 'navigation': navigation, | 147 | 'navigation': navigation, |
226 | 158 | 148 | ||
227 | === modified file 'loggerhead/history.py' | |||
228 | --- loggerhead/history.py 2021-11-15 14:40:11 +0000 | |||
229 | +++ loggerhead/history.py 2022-07-06 12:59:30 +0000 | |||
230 | @@ -34,7 +34,6 @@ | |||
231 | 34 | import textwrap | 34 | import textwrap |
232 | 35 | import threading | 35 | import threading |
233 | 36 | 36 | ||
234 | 37 | from breezy import version_info as breezy_version | ||
235 | 38 | from breezy import tag | 37 | from breezy import tag |
236 | 39 | import breezy.branch | 38 | import breezy.branch |
237 | 40 | import breezy.delta | 39 | import breezy.delta |
238 | @@ -127,18 +126,11 @@ | |||
239 | 127 | except breezy.errors.NoSuchFile: | 126 | except breezy.errors.NoSuchFile: |
240 | 128 | return breezy.revision.NULL_REVISION | 127 | return breezy.revision.NULL_REVISION |
241 | 129 | 128 | ||
254 | 130 | if breezy_version >= (3, 1): | 129 | def report(self, paths, versioned, renamed, copied, modified, |
255 | 131 | def report(self, paths, versioned, renamed, copied, modified, | 130 | exe_change, kind): |
256 | 132 | exe_change, kind): | 131 | return self._report( |
257 | 133 | return self._report( | 132 | paths, versioned, renamed, copied, |
258 | 134 | paths, versioned, renamed, copied, | 133 | modified, exe_change, kind) |
247 | 135 | modified, exe_change, kind) | ||
248 | 136 | else: | ||
249 | 137 | def report(self, file_id, paths, versioned, renamed, modified, | ||
250 | 138 | exe_change, kind): | ||
251 | 139 | return self._report( | ||
252 | 140 | paths, versioned, renamed, None, | ||
253 | 141 | modified, exe_change, kind) | ||
259 | 142 | 134 | ||
260 | 143 | def _report(self, paths, versioned, renamed, copied, modified, | 135 | def _report(self, paths, versioned, renamed, copied, modified, |
261 | 144 | exe_change, kind): | 136 | exe_change, kind): |
262 | @@ -376,6 +368,7 @@ | |||
263 | 376 | def get_short_revision_history_by_fileid(self, file_id): | 368 | def get_short_revision_history_by_fileid(self, file_id): |
264 | 377 | # FIXME: would be awesome if we could get, for a folder, the list of | 369 | # FIXME: would be awesome if we could get, for a folder, the list of |
265 | 378 | # revisions where items within that folder changed.i | 370 | # revisions where items within that folder changed.i |
266 | 371 | # TODO(jelmer): Avoid versionedfile-specific texts | ||
267 | 379 | possible_keys = [(file_id, revid) for revid in self._rev_indices] | 372 | possible_keys = [(file_id, revid) for revid in self._rev_indices] |
268 | 380 | get_parent_map = self._branch.repository.texts.get_parent_map | 373 | get_parent_map = self._branch.repository.texts.get_parent_map |
269 | 381 | # We chunk the requests as this works better with GraphIndex. | 374 | # We chunk the requests as this works better with GraphIndex. |
270 | @@ -478,24 +471,6 @@ | |||
271 | 478 | revid = revid.encode('utf-8') | 471 | revid = revid.encode('utf-8') |
272 | 479 | return revid | 472 | return revid |
273 | 480 | 473 | ||
274 | 481 | def get_file_view(self, revid, file_id): | ||
275 | 482 | """ | ||
276 | 483 | Given a revid and optional path, return a (revlist, revid) for | ||
277 | 484 | navigation through the current scope: from the revid (or the latest | ||
278 | 485 | revision) back to the original revision. | ||
279 | 486 | |||
280 | 487 | If file_id is None, the entire revision history is the list scope. | ||
281 | 488 | """ | ||
282 | 489 | if revid is None: | ||
283 | 490 | revid = self.last_revid | ||
284 | 491 | if file_id is not None: | ||
285 | 492 | revlist = list( | ||
286 | 493 | self.get_short_revision_history_by_fileid(file_id)) | ||
287 | 494 | revlist = self.get_revids_from(revlist, revid) | ||
288 | 495 | else: | ||
289 | 496 | revlist = self.get_revids_from(None, revid) | ||
290 | 497 | return revlist | ||
291 | 498 | |||
292 | 499 | @staticmethod | 474 | @staticmethod |
293 | 500 | def _iterate_sufficiently(iterable, stop_at, extra_rev_count): | 475 | def _iterate_sufficiently(iterable, stop_at, extra_rev_count): |
294 | 501 | """Return a list of iterable. | 476 | """Return a list of iterable. |
295 | @@ -522,15 +497,33 @@ | |||
296 | 522 | result.append(n) | 497 | result.append(n) |
297 | 523 | return result | 498 | return result |
298 | 524 | 499 | ||
300 | 525 | def get_view(self, revid, start_revid, file_id, query=None, | 500 | def _get_file_view(self, revid, file_id): |
301 | 501 | """ | ||
302 | 502 | Given a revid and optional path, return a (revlist, revid) for | ||
303 | 503 | navigation through the current scope: from the revid (or the latest | ||
304 | 504 | revision) back to the original revision. | ||
305 | 505 | |||
306 | 506 | If file_id is None, the entire revision history is the list scope. | ||
307 | 507 | """ | ||
308 | 508 | if revid is None: | ||
309 | 509 | revid = self.last_revid | ||
310 | 510 | if file_id is not None: | ||
311 | 511 | revlist = list( | ||
312 | 512 | self.get_short_revision_history_by_fileid(file_id)) | ||
313 | 513 | revlist = self.get_revids_from(revlist, revid) | ||
314 | 514 | else: | ||
315 | 515 | revlist = self.get_revids_from(None, revid) | ||
316 | 516 | return revlist | ||
317 | 517 | |||
318 | 518 | def get_view(self, revid, start_revid, path, query=None, | ||
319 | 526 | extra_rev_count=None): | 519 | extra_rev_count=None): |
320 | 527 | """ | 520 | """ |
323 | 528 | use the URL parameters (revid, start_revid, file_id, and query) to | 521 | use the URL parameters (revid, start_revid, path, and query) to |
324 | 529 | determine the revision list we're viewing (start_revid, file_id, query) | 522 | determine the revision list we're viewing (start_revid, path, query) |
325 | 530 | and where we are in it (revid). | 523 | and where we are in it (revid). |
326 | 531 | 524 | ||
327 | 532 | - if a query is given, we're viewing query results. | 525 | - if a query is given, we're viewing query results. |
329 | 533 | - if a file_id is given, we're viewing revisions for a specific | 526 | - if a path is given, we're viewing revisions for a specific |
330 | 534 | file. | 527 | file. |
331 | 535 | - if a start_revid is given, we're viewing the branch from a | 528 | - if a start_revid is given, we're viewing the branch from a |
332 | 536 | specific revision up the tree. | 529 | specific revision up the tree. |
333 | @@ -548,14 +541,19 @@ | |||
334 | 548 | - start_revid: starting revision of this view | 541 | - start_revid: starting revision of this view |
335 | 549 | - revid_list: list of revision ids for this view | 542 | - revid_list: list of revision ids for this view |
336 | 550 | 543 | ||
338 | 551 | file_id and query are never changed so aren't returned, but they may | 544 | path and query are never changed so aren't returned, but they may |
339 | 552 | contain vital context for future url navigation. | 545 | contain vital context for future url navigation. |
340 | 553 | """ | 546 | """ |
341 | 554 | if start_revid is None: | 547 | if start_revid is None: |
342 | 555 | start_revid = self.last_revid | 548 | start_revid = self.last_revid |
343 | 556 | 549 | ||
344 | 557 | if query is None: | 550 | if query is None: |
346 | 558 | revid_list = self.get_file_view(start_revid, file_id) | 551 | repo = self._branch.repository |
347 | 552 | if path is not None: | ||
348 | 553 | file_id = repo.revision_tree(start_revid).path2id(path) | ||
349 | 554 | else: | ||
350 | 555 | file_id = None | ||
351 | 556 | revid_list = self._get_file_view(start_revid, file_id) | ||
352 | 559 | revid_list = self._iterate_sufficiently(revid_list, revid, | 557 | revid_list = self._iterate_sufficiently(revid_list, revid, |
353 | 560 | extra_rev_count) | 558 | extra_rev_count) |
354 | 561 | if revid is None: | 559 | if revid is None: |
355 | @@ -563,15 +561,17 @@ | |||
356 | 563 | if revid not in revid_list: | 561 | if revid not in revid_list: |
357 | 564 | # if the given revid is not in the revlist, use a revlist that | 562 | # if the given revid is not in the revlist, use a revlist that |
358 | 565 | # starts at the given revid. | 563 | # starts at the given revid. |
360 | 566 | revid_list = self.get_file_view(revid, file_id) | 564 | revid_list = self._get_file_view(revid, file_id) |
361 | 567 | revid_list = self._iterate_sufficiently(revid_list, revid, | 565 | revid_list = self._iterate_sufficiently(revid_list, revid, |
362 | 568 | extra_rev_count) | 566 | extra_rev_count) |
363 | 569 | start_revid = revid | 567 | start_revid = revid |
364 | 570 | return revid, start_revid, revid_list | 568 | return revid, start_revid, revid_list |
365 | 569 | else: | ||
366 | 570 | file_id = None | ||
367 | 571 | 571 | ||
368 | 572 | # potentially limit the search | 572 | # potentially limit the search |
369 | 573 | if file_id is not None: | 573 | if file_id is not None: |
371 | 574 | revid_list = self.get_file_view(start_revid, file_id) | 574 | revid_list = self._get_file_view(start_revid, file_id) |
372 | 575 | else: | 575 | else: |
373 | 576 | revid_list = None | 576 | revid_list = None |
374 | 577 | revid_list = search.search_revisions(self._branch, query) | 577 | revid_list = search.search_revisions(self._branch, query) |
375 | @@ -588,18 +588,13 @@ | |||
376 | 588 | def revision_tree(self, revid): | 588 | def revision_tree(self, revid): |
377 | 589 | return self._branch.repository.revision_tree(revid) | 589 | return self._branch.repository.revision_tree(revid) |
378 | 590 | 590 | ||
391 | 591 | def get_path(self, revid, file_id): | 591 | def file_exists(self, revid, path): |
392 | 592 | if (file_id is None) or (file_id == ''): | 592 | if (len(path) > 0) and not path.startswith('/'): |
393 | 593 | return '' | 593 | path = '/' + path |
394 | 594 | path = self.revision_tree(revid).id2path(file_id) | 594 | try: |
395 | 595 | if (len(path) > 0) and not path.startswith('/'): | 595 | return self.revision_tree(revid).has_filename(path) |
396 | 596 | path = '/' + path | 596 | except breezy.errors.NoSuchRevision: |
397 | 597 | return path | 597 | return False |
386 | 598 | |||
387 | 599 | def get_file_id(self, revid, path): | ||
388 | 600 | if (len(path) > 0) and not path.startswith('/'): | ||
389 | 601 | path = '/' + path | ||
390 | 602 | return self.revision_tree(revid).path2id(path) | ||
398 | 603 | 598 | ||
399 | 604 | def get_merge_point_list(self, revid): | 599 | def get_merge_point_list(self, revid): |
400 | 605 | """ | 600 | """ |
401 | @@ -786,32 +781,15 @@ | |||
402 | 786 | return (display_path, breezy.osutils.basename(path), | 781 | return (display_path, breezy.osutils.basename(path), |
403 | 787 | rev_tree.get_file_text(path)) | 782 | rev_tree.get_file_text(path)) |
404 | 788 | 783 | ||
405 | 789 | def get_file_by_fileid(self, fileid, revid): | ||
406 | 790 | """Returns (path, filename, file contents)""" | ||
407 | 791 | if not isinstance(fileid, bytes): | ||
408 | 792 | raise TypeError(fileid) | ||
409 | 793 | if not isinstance(revid, bytes): | ||
410 | 794 | raise TypeError(revid) | ||
411 | 795 | rev_tree = self._branch.repository.revision_tree(revid) | ||
412 | 796 | path = rev_tree.id2path(fileid) | ||
413 | 797 | display_path = path | ||
414 | 798 | if not display_path.startswith('/'): | ||
415 | 799 | path = '/' + path | ||
416 | 800 | return (display_path, breezy.osutils.basename(path), | ||
417 | 801 | rev_tree.get_file_text(path)) | ||
418 | 802 | |||
419 | 803 | def file_changes_for_revision_ids(self, old_revid, new_revid): | 784 | def file_changes_for_revision_ids(self, old_revid, new_revid): |
420 | 804 | """ | 785 | """ |
421 | 805 | Return a nested data structure containing the changes in a delta:: | 786 | Return a nested data structure containing the changes in a delta:: |
422 | 806 | 787 | ||
431 | 807 | added: list((filename, file_id)), | 788 | added: list((filename)), |
432 | 808 | renamed: list((old_filename, new_filename, file_id)), | 789 | renamed: list((old_filename, new_filename)), |
433 | 809 | deleted: list((filename, file_id)), | 790 | deleted: list((filename)), |
434 | 810 | modified: list( | 791 | modified: list((filename)), |
435 | 811 | filename: str, | 792 | text_changes: list((filename)), |
428 | 812 | file_id: str, | ||
429 | 813 | ), | ||
430 | 814 | text_changes: list((filename, file_id)), | ||
436 | 815 | """ | 793 | """ |
437 | 816 | repo = self._branch.repository | 794 | repo = self._branch.repository |
438 | 817 | if (breezy.revision.is_null(old_revid) or | 795 | if (breezy.revision.is_null(old_revid) or |
439 | 818 | 796 | ||
440 | === modified file 'loggerhead/templates/changelog.pt' | |||
441 | --- loggerhead/templates/changelog.pt 2012-02-02 07:42:24 +0000 | |||
442 | +++ loggerhead/templates/changelog.pt 2022-07-06 12:59:30 +0000 | |||
443 | @@ -39,7 +39,7 @@ | |||
444 | 39 | </tal:no-link> | 39 | </tal:no-link> |
445 | 40 | <tal:block condition="changes"> | 40 | <tal:block condition="changes"> |
446 | 41 | » Changes | 41 | » Changes |
448 | 42 | <tal:block condition="filter_file_id">to <span tal:content="python:history.get_path(revid, filter_file_id)" /></tal:block> | 42 | <tal:block condition="filter_path">to <span tal:content="filter_path" /></tal:block> |
449 | 43 | <tal:block condition="start_revid">from revision | 43 | <tal:block condition="start_revid">from revision |
450 | 44 | <span tal:content="python:history.get_revno(start_revid)"/> | 44 | <span tal:content="python:history.get_revno(start_revid)"/> |
451 | 45 | </tal:block> | 45 | </tal:block> |
452 | 46 | 46 | ||
453 | === modified file 'loggerhead/templates/inventory.pt' | |||
454 | --- loggerhead/templates/inventory.pt 2018-10-20 16:06:44 +0000 | |||
455 | +++ loggerhead/templates/inventory.pt 2022-07-06 12:59:30 +0000 | |||
456 | @@ -94,7 +94,7 @@ | |||
457 | 94 | <td class="date" tal:content="python:util.hide_email(file.change.committer)"></td> | 94 | <td class="date" tal:content="python:util.hide_email(file.change.committer)"></td> |
458 | 95 | <td class="autcell" tal:content="python:file.change.comment[:50]"></td> | 95 | <td class="autcell" tal:content="python:file.change.comment[:50]"></td> |
459 | 96 | <td class="timedate2"></td><!-- not showing sizes of folders --> | 96 | <td class="timedate2"></td><!-- not showing sizes of folders --> |
461 | 97 | <td class="expcell"><a tal:attributes="href python:url(['/changes'], start_revid=start_revid, filter_file_id=file.file_id); | 97 | <td class="expcell"><a tal:attributes="href python:url(['/changes'], start_revid=start_revid, filter_path=file.absolutepath); |
462 | 98 | title string:Show revision ${file/change/revno}"> | 98 | title string:Show revision ${file/change/revno}"> |
463 | 99 | <img tal:attributes="src python:branch.static_url('/static/images/ico_planilla.gif')" alt="Diff" /> | 99 | <img tal:attributes="src python:branch.static_url('/static/images/ico_planilla.gif')" alt="Diff" /> |
464 | 100 | </a> | 100 | </a> |
465 | @@ -119,7 +119,7 @@ | |||
466 | 119 | <td class="date" tal:content="python:util.hide_email(file.change.committer)"></td> | 119 | <td class="date" tal:content="python:util.hide_email(file.change.committer)"></td> |
467 | 120 | <td class="autcell" tal:content="python:file.change.comment[:50]"></td> | 120 | <td class="autcell" tal:content="python:file.change.comment[:50]"></td> |
468 | 121 | <td class="timedate2">.</td> | 121 | <td class="timedate2">.</td> |
470 | 122 | <td class="expcell"><a tal:attributes="href python:url(['/changes'], start_revid=start_revid, filter_file_id=file.file_id); | 122 | <td class="expcell"><a tal:attributes="href python:url(['/changes'], start_revid=start_revid, filter_path=file.absolutepath); |
471 | 123 | title string:Show revision ${file/change/revno}"> | 123 | title string:Show revision ${file/change/revno}"> |
472 | 124 | <img tal:attributes="src python:branch.static_url('/static/images/ico_planilla.gif'); | 124 | <img tal:attributes="src python:branch.static_url('/static/images/ico_planilla.gif'); |
473 | 125 | title string:Show revision ${file/change/revno}" /> | 125 | title string:Show revision ${file/change/revno}" /> |
474 | @@ -157,7 +157,7 @@ | |||
475 | 157 | </a> | 157 | </a> |
476 | 158 | </td> | 158 | </td> |
477 | 159 | <td class="expcell"> | 159 | <td class="expcell"> |
479 | 160 | <a tal:attributes="href python:url(['/download', file.revid.decode('utf-8'), file.file_id.decode('utf-8'), file.filename]); | 160 | <a tal:attributes="href python:url(['/download', file.revid.decode('utf-8'), file.filename]); |
480 | 161 | title string:Download ${file/filename} at revision ${file/change/revno}"> | 161 | title string:Download ${file/filename} at revision ${file/change/revno}"> |
481 | 162 | <img tal:attributes="src python:branch.static_url('/static/images/ico_file_download.gif')" alt="Download File" /> | 162 | <img tal:attributes="src python:branch.static_url('/static/images/ico_file_download.gif')" alt="Download File" /> |
482 | 163 | </a> | 163 | </a> |
483 | 164 | 164 | ||
484 | === modified file 'loggerhead/templates/search-box.pt' | |||
485 | --- loggerhead/templates/search-box.pt 2008-08-13 17:24:10 +0000 | |||
486 | +++ loggerhead/templates/search-box.pt 2022-07-06 12:59:30 +0000 | |||
487 | @@ -1,8 +1,7 @@ | |||
488 | 1 | <tal:search-box> | 1 | <tal:search-box> |
489 | 2 | <form tal:attributes="action python:branch.url('/changes', | 2 | <form tal:attributes="action python:branch.url('/changes', |
490 | 3 | start_revid=getattr(navigation, | 3 | start_revid=getattr(navigation, |
493 | 4 | 'start_revid', None), | 4 | 'start_revid', None))"> |
492 | 5 | file_id=getattr(navigation, 'file_id', None))"> | ||
494 | 6 | <label>search:</label> | 5 | <label>search:</label> |
495 | 7 | <input type="search" name="q" id="q" autocomplete="off" onblur="hide_search();" /> | 6 | <input type="search" name="q" id="q" autocomplete="off" onblur="hide_search();" /> |
496 | 8 | </form> | 7 | </form> |
497 | 9 | 8 | ||
498 | === modified file 'loggerhead/templates/view.pt' | |||
499 | --- loggerhead/templates/view.pt 2020-06-04 19:21:17 +0000 | |||
500 | +++ loggerhead/templates/view.pt 2022-07-06 12:59:30 +0000 | |||
501 | @@ -59,7 +59,7 @@ | |||
502 | 59 | <a tal:attributes="href python:url(['/revision', change.revno], clear=1)">view revision</a> | 59 | <a tal:attributes="href python:url(['/revision', change.revno], clear=1)">view revision</a> |
503 | 60 | </li> | 60 | </li> |
504 | 61 | <li> | 61 | <li> |
506 | 62 | <a tal:attributes="href python:url(['/changes'], clear=1, filter_file_id=file_id)" | 62 | <a tal:attributes="href python:url(['/changes'], clear=1, filter_path=file_path)" |
507 | 63 | >view changes to this file</a> | 63 | >view changes to this file</a> |
508 | 64 | </li> | 64 | </li> |
509 | 65 | <li id="last"> | 65 | <li id="last"> |
510 | 66 | 66 | ||
511 | === modified file 'loggerhead/tests/fixtures.py' | |||
512 | --- loggerhead/tests/fixtures.py 2018-10-20 13:45:31 +0000 | |||
513 | +++ loggerhead/tests/fixtures.py 2022-07-06 12:59:30 +0000 | |||
514 | @@ -36,8 +36,7 @@ | |||
515 | 36 | filenames = ['myfilename', 'anotherfile<'] | 36 | filenames = ['myfilename', 'anotherfile<'] |
516 | 37 | self.testcase.build_tree_contents( | 37 | self.testcase.build_tree_contents( |
517 | 38 | (filename, self.filecontents) for filename in filenames) | 38 | (filename, self.filecontents) for filename in filenames) |
521 | 39 | for filename in filenames: | 39 | self.tree.add(filenames) |
522 | 40 | self.tree.add(filename, ('%s-id' % filename).encode('utf-8')) | 40 | self.path = 'myfilename' |
520 | 41 | self.fileid = self.tree.path2id('myfilename') | ||
523 | 42 | self.msg = 'a very exciting commit message <' | 41 | self.msg = 'a very exciting commit message <' |
524 | 43 | self.revid = self.tree.commit(message=self.msg) | 42 | self.revid = self.tree.commit(message=self.msg) |
525 | 44 | 43 | ||
526 | === modified file 'loggerhead/tests/test_controllers.py' | |||
527 | --- loggerhead/tests/test_controllers.py 2021-03-29 11:18:58 +0000 | |||
528 | +++ loggerhead/tests/test_controllers.py 2022-07-06 12:59:30 +0000 | |||
529 | @@ -221,12 +221,12 @@ | |||
530 | 221 | 221 | ||
531 | 222 | class TestAnnotateUI(BasicTests): | 222 | class TestAnnotateUI(BasicTests): |
532 | 223 | 223 | ||
534 | 224 | def make_annotate_ui_for_file_history(self, file_id, rev_ids_texts): | 224 | def make_annotate_ui_for_file_history(self, filename, rev_ids_texts): |
535 | 225 | tree = self.make_branch_and_tree('.') | 225 | tree = self.make_branch_and_tree('.') |
538 | 226 | self.build_tree_contents([('filename', '')]) | 226 | self.build_tree_contents([(filename, '')]) |
539 | 227 | tree.add(['filename'], [file_id]) | 227 | tree.add([filename]) |
540 | 228 | for rev_id, text, message in rev_ids_texts: | 228 | for rev_id, text, message in rev_ids_texts: |
542 | 229 | self.build_tree_contents([('filename', text)]) | 229 | self.build_tree_contents([(filename, text)]) |
543 | 230 | tree.commit(rev_id=rev_id, message=message) | 230 | tree.commit(rev_id=rev_id, message=message) |
544 | 231 | tree.branch.lock_read() | 231 | tree.branch.lock_read() |
545 | 232 | self.addCleanup(tree.branch.unlock) | 232 | self.addCleanup(tree.branch.unlock) |
546 | @@ -235,12 +235,11 @@ | |||
547 | 235 | 235 | ||
548 | 236 | def test_annotate_file(self): | 236 | def test_annotate_file(self): |
549 | 237 | history = [(b'rev1', b'old\nold\n', '.'), (b'rev2', b'new\nold\n', '.')] | 237 | history = [(b'rev1', b'old\nold\n', '.'), (b'rev2', b'new\nold\n', '.')] |
551 | 238 | ann_ui = self.make_annotate_ui_for_file_history(b'file_id', history) | 238 | ann_ui = self.make_annotate_ui_for_file_history('filename', history) |
552 | 239 | # A lot of this state is set up by __call__, but we'll do it directly | 239 | # A lot of this state is set up by __call__, but we'll do it directly |
553 | 240 | # here. | 240 | # here. |
554 | 241 | ann_ui.args = ['rev2'] | 241 | ann_ui.args = ['rev2'] |
557 | 242 | annotate_info = ann_ui.get_values(u'filename', | 242 | annotate_info = ann_ui.get_values(u'filename', kwargs={}, headers={}) |
556 | 243 | kwargs={'file_id': 'file_id'}, headers={}) | ||
558 | 244 | annotated = annotate_info['annotated'] | 243 | annotated = annotate_info['annotated'] |
559 | 245 | self.assertEqual(2, len(annotated)) | 244 | self.assertEqual(2, len(annotated)) |
560 | 246 | self.assertEqual('2', annotated[1].change.revno) | 245 | self.assertEqual('2', annotated[1].change.revno) |
561 | @@ -249,32 +248,30 @@ | |||
562 | 249 | def test_annotate_empty_comment(self): | 248 | def test_annotate_empty_comment(self): |
563 | 250 | # Testing empty comment handling without breaking | 249 | # Testing empty comment handling without breaking |
564 | 251 | history = [(b'rev1', b'old\nold\n', '.'), (b'rev2', b'new\nold\n', '')] | 250 | history = [(b'rev1', b'old\nold\n', '.'), (b'rev2', b'new\nold\n', '')] |
566 | 252 | ann_ui = self.make_annotate_ui_for_file_history(b'file_id', history) | 251 | ann_ui = self.make_annotate_ui_for_file_history('filename', history) |
567 | 253 | ann_ui.args = ['rev2'] | 252 | ann_ui.args = ['rev2'] |
570 | 254 | ann_ui.get_values( | 253 | ann_ui.get_values(u'filename', kwargs={}, headers={}) |
569 | 255 | u'filename', kwargs={'file_id': 'file_id'}, headers={}) | ||
571 | 256 | 254 | ||
572 | 257 | def test_annotate_file_zero_sized(self): | 255 | def test_annotate_file_zero_sized(self): |
573 | 258 | # Test against a zero-sized file without breaking. No annotation | 256 | # Test against a zero-sized file without breaking. No annotation |
574 | 259 | # must be present. | 257 | # must be present. |
575 | 260 | history = [(b'rev1', b'', '.')] | 258 | history = [(b'rev1', b'', '.')] |
577 | 261 | ann_ui = self.make_annotate_ui_for_file_history(b'file_id', history) | 259 | ann_ui = self.make_annotate_ui_for_file_history('filename', history) |
578 | 262 | ann_ui.args = ['rev1'] | 260 | ann_ui.args = ['rev1'] |
581 | 263 | annotate_info = ann_ui.get_values(u'filename', | 261 | annotate_info = ann_ui.get_values(u'filename', kwargs={}, headers={}) |
580 | 264 | kwargs={'file_id': 'file_id'}, headers={}) | ||
582 | 265 | annotated = annotate_info['annotated'] | 262 | annotated = annotate_info['annotated'] |
583 | 266 | self.assertEqual(0, len(annotated)) | 263 | self.assertEqual(0, len(annotated)) |
584 | 267 | 264 | ||
585 | 268 | def test_annotate_nonexistent_file(self): | 265 | def test_annotate_nonexistent_file(self): |
586 | 269 | history = [(b'rev1', b'', '.')] | 266 | history = [(b'rev1', b'', '.')] |
588 | 270 | ann_ui = self.make_annotate_ui_for_file_history(b'file_id', history) | 267 | ann_ui = self.make_annotate_ui_for_file_history('filename', history) |
589 | 271 | ann_ui.args = ['rev1'] | 268 | ann_ui.args = ['rev1'] |
590 | 272 | self.assertRaises( | 269 | self.assertRaises( |
591 | 273 | HTTPNotFound, ann_ui.get_values, u'not-filename', {}, {}) | 270 | HTTPNotFound, ann_ui.get_values, u'not-filename', {}, {}) |
592 | 274 | 271 | ||
593 | 275 | def test_annotate_nonexistent_rev(self): | 272 | def test_annotate_nonexistent_rev(self): |
594 | 276 | history = [(b'rev1', b'', '.')] | 273 | history = [(b'rev1', b'', '.')] |
596 | 277 | ann_ui = self.make_annotate_ui_for_file_history(b'file_id', history) | 274 | ann_ui = self.make_annotate_ui_for_file_history('filename', history) |
597 | 278 | ann_ui.args = ['norev'] | 275 | ann_ui.args = ['norev'] |
598 | 279 | self.assertRaises( | 276 | self.assertRaises( |
599 | 280 | HTTPNotFound, ann_ui.get_values, u'not-filename', {}, {}) | 277 | HTTPNotFound, ann_ui.get_values, u'not-filename', {}, {}) |
600 | @@ -433,15 +430,6 @@ | |||
601 | 433 | response, | 430 | response, |
602 | 434 | MatchesDownloadHeaders('myfilename', 'application/octet-stream')) | 431 | MatchesDownloadHeaders('myfilename', 'application/octet-stream')) |
603 | 435 | 432 | ||
604 | 436 | def test_download_with_revid(self): | ||
605 | 437 | app = self.setUpLoggerhead() | ||
606 | 438 | response = app.get('/download/1/myfilename-id/myfilename') | ||
607 | 439 | self.assertEqual( | ||
608 | 440 | b'some\nmultiline\ndata\nwith<htmlspecialchars\n', response.body) | ||
609 | 441 | self.assertThat( | ||
610 | 442 | response, | ||
611 | 443 | MatchesDownloadHeaders('myfilename', 'application/octet-stream')) | ||
612 | 444 | |||
613 | 445 | def test_download_bad_revision(self): | 433 | def test_download_bad_revision(self): |
614 | 446 | app = self.setUpLoggerhead() | 434 | app = self.setUpLoggerhead() |
615 | 447 | e = self.assertRaises( | 435 | e = self.assertRaises( |
616 | @@ -449,7 +437,7 @@ | |||
617 | 449 | app.get, '/download/norev/myfilename') | 437 | app.get, '/download/norev/myfilename') |
618 | 450 | self.assertContainsRe(str(e), '404 Not Found') | 438 | self.assertContainsRe(str(e), '404 Not Found') |
619 | 451 | 439 | ||
621 | 452 | def test_download_bad_fileid(self): | 440 | def test_download_bad_filename(self): |
622 | 453 | app = self.setUpLoggerhead() | 441 | app = self.setUpLoggerhead() |
623 | 454 | e = self.assertRaises( | 442 | e = self.assertRaises( |
624 | 455 | AppError, | 443 | AppError, |
625 | 456 | 444 | ||
626 | === modified file 'loggerhead/tests/test_simple.py' | |||
627 | --- loggerhead/tests/test_simple.py 2021-11-15 14:40:11 +0000 | |||
628 | +++ loggerhead/tests/test_simple.py 2022-07-06 12:59:30 +0000 | |||
629 | @@ -78,7 +78,7 @@ | |||
630 | 78 | # XXX: This could be cleaned up more... -- mbp 2011-11-25 | 78 | # XXX: This could be cleaned up more... -- mbp 2011-11-25 |
631 | 79 | self.useFixture(self.sample_branch_fixture) | 79 | self.useFixture(self.sample_branch_fixture) |
632 | 80 | self.tree = self.sample_branch_fixture.tree | 80 | self.tree = self.sample_branch_fixture.tree |
634 | 81 | self.fileid = self.sample_branch_fixture.fileid | 81 | self.path = self.sample_branch_fixture.path |
635 | 82 | self.filecontents = self.sample_branch_fixture.filecontents | 82 | self.filecontents = self.sample_branch_fixture.filecontents |
636 | 83 | self.msg = self.sample_branch_fixture.msg | 83 | self.msg = self.sample_branch_fixture.msg |
637 | 84 | 84 | ||
638 | @@ -95,7 +95,7 @@ | |||
639 | 95 | 95 | ||
640 | 96 | def test_changes_for_file(self): | 96 | def test_changes_for_file(self): |
641 | 97 | app = self.setUpLoggerhead() | 97 | app = self.setUpLoggerhead() |
643 | 98 | res = app.get('/changes?filter_file_id=myfilename-id') | 98 | res = app.get('/changes?filter_path=%s' % self.path) |
644 | 99 | res.mustcontain(escape(self.msg)) | 99 | res.mustcontain(escape(self.msg)) |
645 | 100 | 100 | ||
646 | 101 | def test_changes_branch_from(self): | 101 | def test_changes_branch_from(self): |
647 | @@ -111,7 +111,7 @@ | |||
648 | 111 | 111 | ||
649 | 112 | def test_annotate(self): | 112 | def test_annotate(self): |
650 | 113 | app = self.setUpLoggerhead() | 113 | app = self.setUpLoggerhead() |
652 | 114 | res = app.get('/annotate', params={'file_id': self.fileid}) | 114 | res = app.get('/annotate/1/%s' % self.path, params={}) |
653 | 115 | # If pygments is installed, it inserts <span class="pyg" content into | 115 | # If pygments is installed, it inserts <span class="pyg" content into |
654 | 116 | # the output, to trigger highlighting. And it specifically highlights | 116 | # the output, to trigger highlighting. And it specifically highlights |
655 | 117 | # the < that we are interested in seeing in the output. | 117 | # the < that we are interested in seeing in the output. |
656 | @@ -137,8 +137,6 @@ | |||
657 | 137 | res.mustcontain('myfilename') | 137 | res.mustcontain('myfilename') |
658 | 138 | res = app.get('/files/1/') | 138 | res = app.get('/files/1/') |
659 | 139 | res.mustcontain('myfilename') | 139 | res.mustcontain('myfilename') |
660 | 140 | res = app.get('/files/1/?file_id=' + self.tree.path2id('').decode('utf-8')) | ||
661 | 141 | res.mustcontain('myfilename') | ||
662 | 142 | 140 | ||
663 | 143 | def test_inventory_bad_rev_404(self): | 141 | def test_inventory_bad_rev_404(self): |
664 | 144 | app = self.setUpLoggerhead() | 142 | app = self.setUpLoggerhead() |
665 | @@ -148,7 +146,6 @@ | |||
666 | 148 | def test_inventory_bad_path_404(self): | 146 | def test_inventory_bad_path_404(self): |
667 | 149 | app = self.setUpLoggerhead() | 147 | app = self.setUpLoggerhead() |
668 | 150 | res = app.get('/files/1/hooha', status=404) | 148 | res = app.get('/files/1/hooha', status=404) |
669 | 151 | res = app.get('/files/1?file_id=dssadsada', status=404) | ||
670 | 152 | 149 | ||
671 | 153 | def test_revision(self): | 150 | def test_revision(self): |
672 | 154 | app = self.setUpLoggerhead() | 151 | app = self.setUpLoggerhead() |
673 | 155 | 152 | ||
674 | === modified file 'loggerhead/util.py' | |||
675 | --- loggerhead/util.py 2021-11-15 14:40:11 +0000 | |||
676 | +++ loggerhead/util.py 2022-07-06 12:59:30 +0000 | |||
677 | @@ -409,7 +409,7 @@ | |||
678 | 409 | navigation.next_page_revid) | 409 | navigation.next_page_revid) |
679 | 410 | start_revno = navigation.history.get_revno(navigation.start_revid) | 410 | start_revno = navigation.history.get_revno(navigation.start_revid) |
680 | 411 | 411 | ||
682 | 412 | params = {'filter_file_id': navigation.filter_file_id} | 412 | params = {'filter_path': navigation.filter_path} |
683 | 413 | if getattr(navigation, 'query', None) is not None: | 413 | if getattr(navigation, 'query', None) is not None: |
684 | 414 | params['q'] = navigation.query | 414 | params['q'] = navigation.query |
685 | 415 | 415 | ||
686 | @@ -533,9 +533,7 @@ | |||
687 | 533 | # the current beginning of navigation (navigation continues back to | 533 | # the current beginning of navigation (navigation continues back to |
688 | 534 | # the original revision) -- this defines an 'alternate mainline' | 534 | # the original revision) -- this defines an 'alternate mainline' |
689 | 535 | # when the user navigates into a branch. | 535 | # when the user navigates into a branch. |
693 | 536 | # - file_id | 536 | # - filter_path |
691 | 537 | # the file being looked at | ||
692 | 538 | # - filter_file_id | ||
694 | 539 | # if navigating the revisions that touched a file | 537 | # if navigating the revisions that touched a file |
695 | 540 | # - q (query) | 538 | # - q (query) |
696 | 541 | # if navigating the revisions that matched a search query | 539 | # if navigating the revisions that matched a search query |
697 | @@ -553,7 +551,7 @@ | |||
698 | 553 | 551 | ||
699 | 554 | t_context = threading.local() | 552 | t_context = threading.local() |
700 | 555 | _valid = ( | 553 | _valid = ( |
702 | 556 | 'start_revid', 'filter_file_id', 'q', 'remember', 'compare_revid', 'sort') | 554 | 'start_revid', 'filter_path', 'q', 'remember', 'compare_revid', 'sort') |
703 | 557 | 555 | ||
704 | 558 | 556 | ||
705 | 559 | def set_context(map): | 557 | def set_context(map): |
This does break some old (horrible) URLs, but it seems ultimately necessary, so I'm OK with this. Let's see what the test suite makes of it.