Merge lp:~mnordhoff/loggerhead/config_app_stuff into lp:loggerhead

Proposed by Matt Nordhoff
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mnordhoff/loggerhead/config_app_stuff
Merge into: lp:loggerhead
Diff against target: None lines
To merge this branch: bzr merge lp:~mnordhoff/loggerhead/config_app_stuff
Reviewer Review Type Date Requested Status
Martin Albisetti Approve
Review via email: mp+6519@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Matt Nordhoff (mnordhoff) wrote :

Good morning,

Some improvements to loggerhead.apps.config.Project's interaction with BranchWSGIApp:

* Use BranchWSGIApp.served_url instead of inventing a 'branch_url' attribute.

* Don't set so many attributes on the BranchWSGIApp object, just 'description' and 'name'. (The constructor can handle the rest.)

* Remove '_src_folder' and '_view_config' from view_data_by_name as they were unused.

* Fix a latent semi-bug: it called BranchWSGIApp(friendly_name=view_name), then set BranchWSGIApp.friendly_name to friendly_name. (I decided to go with friendly_name.)

This was inspired by my investigation into bug #375948 (the branch_url method got clobbered), although I already fixed it a different way (just by renaming it).

Mostly this isn't very important, but I feel that reducing the number of attributes being set is safer, plus I did a little cleanup.

You should sanity-check my decision regarding served_url. This means it'll fall back to public_branch if it's set, but that seems okay to me. Aside from that, I think it's fine. Probably. ;D

So...yeah. :)

Revision history for this message
Martin Albisetti (beuno) wrote :

Merge! :)
Thanks Matt.

review: Approve

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loggerhead/apps/config.py'
2--- loggerhead/apps/config.py 2008-12-15 21:23:24 +0000
3+++ loggerhead/apps/config.py 2009-05-13 13:14:04 +0000
4@@ -108,20 +108,17 @@
5 friendly_name = history.get_config().get_nickname()
6 if friendly_name is None:
7 friendly_name = view_name
8+ branch_url = self._get_branch_url(view, view_config, view_name)
9+ description = self._get_description(view, view_config, history)
10 self.view_data_by_name[view_name] = {
11 'branch_path': folder,
12- 'args': (view_name, view_config, self.graph_cache),
13- 'description': self._get_description(view,
14- view_config,
15- history),
16- '_src_folder': folder,
17- '_view_config': view_config,
18+ 'config': view_config,
19+ 'description': description,
20 'friendly_name': friendly_name,
21+ 'graph_cache': self.graph_cache,
22 'name': view_name,
23+ 'served_url': branch_url,
24 }
25- branch_url = self._get_branch_url(view, view_config, view_name)
26- if branch_url is not None:
27- self.view_data_by_name[view_name]['branch_url'] = branch_url
28 self.view_names.append(view_name)
29 finally:
30 b.unlock()
31@@ -132,12 +129,13 @@
32 return None
33 view_data = view_data.copy()
34 branch_path = view_data.pop('branch_path')
35- args = view_data.pop('args')
36+ description = view_data.pop('description')
37+ name = view_data.pop('name')
38 b = bzrlib.branch.Branch.open(branch_path)
39 b.lock_read()
40- view = BranchWSGIApp(b, *args)
41- for k in view_data:
42- setattr(view, k, view_data[k])
43+ view = BranchWSGIApp(b, **view_data)
44+ view.description = description
45+ view.name = name
46 return view
47
48 def call(self, environ, start_response):
49
50=== modified file 'loggerhead/templates/browse.pt'
51--- loggerhead/templates/browse.pt 2008-10-18 00:23:09 +0000
52+++ loggerhead/templates/browse.pt 2009-05-13 13:14:04 +0000
53@@ -43,12 +43,12 @@
54 </a>
55 </td>
56 </tr>
57- <tr tal:condition="view/branch_url">
58+ <tr tal:condition="view/served_url">
59 <td class="name">
60 </td>
61 <td class="description url" colspan="2">
62- <a tal:attributes="href view/branch_url"
63- tal:content="view/branch_url" />
64+ <a tal:attributes="href view/served_url"
65+ tal:content="view/served_url" />
66 </td>
67 </tr>
68 </tal:block>

Subscribers

People subscribed via source and target branches