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
=== modified file 'loggerhead/apps/config.py'
--- loggerhead/apps/config.py 2008-12-15 21:23:24 +0000
+++ loggerhead/apps/config.py 2009-05-13 13:14:04 +0000
@@ -108,20 +108,17 @@
108 friendly_name = history.get_config().get_nickname()108 friendly_name = history.get_config().get_nickname()
109 if friendly_name is None:109 if friendly_name is None:
110 friendly_name = view_name110 friendly_name = view_name
111 branch_url = self._get_branch_url(view, view_config, view_name)
112 description = self._get_description(view, view_config, history)
111 self.view_data_by_name[view_name] = {113 self.view_data_by_name[view_name] = {
112 'branch_path': folder,114 'branch_path': folder,
113 'args': (view_name, view_config, self.graph_cache),115 'config': view_config,
114 'description': self._get_description(view,116 'description': description,
115 view_config,
116 history),
117 '_src_folder': folder,
118 '_view_config': view_config,
119 'friendly_name': friendly_name,117 'friendly_name': friendly_name,
118 'graph_cache': self.graph_cache,
120 'name': view_name,119 'name': view_name,
120 'served_url': branch_url,
121 }121 }
122 branch_url = self._get_branch_url(view, view_config, view_name)
123 if branch_url is not None:
124 self.view_data_by_name[view_name]['branch_url'] = branch_url
125 self.view_names.append(view_name)122 self.view_names.append(view_name)
126 finally:123 finally:
127 b.unlock()124 b.unlock()
@@ -132,12 +129,13 @@
132 return None129 return None
133 view_data = view_data.copy()130 view_data = view_data.copy()
134 branch_path = view_data.pop('branch_path')131 branch_path = view_data.pop('branch_path')
135 args = view_data.pop('args')132 description = view_data.pop('description')
133 name = view_data.pop('name')
136 b = bzrlib.branch.Branch.open(branch_path)134 b = bzrlib.branch.Branch.open(branch_path)
137 b.lock_read()135 b.lock_read()
138 view = BranchWSGIApp(b, *args)136 view = BranchWSGIApp(b, **view_data)
139 for k in view_data:137 view.description = description
140 setattr(view, k, view_data[k])138 view.name = name
141 return view139 return view
142140
143 def call(self, environ, start_response):141 def call(self, environ, start_response):
144142
=== modified file 'loggerhead/templates/browse.pt'
--- loggerhead/templates/browse.pt 2008-10-18 00:23:09 +0000
+++ loggerhead/templates/browse.pt 2009-05-13 13:14:04 +0000
@@ -43,12 +43,12 @@
43 </a>43 </a>
44 </td>44 </td>
45 </tr>45 </tr>
46 <tr tal:condition="view/branch_url">46 <tr tal:condition="view/served_url">
47 <td class="name">47 <td class="name">
48 </td>48 </td>
49 <td class="description url" colspan="2">49 <td class="description url" colspan="2">
50 <a tal:attributes="href view/branch_url"50 <a tal:attributes="href view/served_url"
51 tal:content="view/branch_url" />51 tal:content="view/served_url" />
52 </td>52 </td>
53 </tr>53 </tr>
54 </tal:block>54 </tal:block>

Subscribers

People subscribed via source and target branches