Merge lp:~beuno/loggerhead/serve-config into lp:loggerhead
- serve-config
- Merge into trunk-rich
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~beuno/loggerhead/serve-config |
Merge into: | lp:loggerhead |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~beuno/loggerhead/serve-config |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hudson-Doyle | Approve | ||
Matt Nordhoff | Needs Fixing | ||
Review via email: mp+6821@code.launchpad.net |
Commit message
Description of the change
Martin Albisetti (beuno) wrote : | # |
Matt Nordhoff (mnordhoff) wrote : | # |
Without doing a real review, I spotted a couple trivial whitespace issues:
* The copyright headers tend to have 2 spaces between "2009" and "Canonical".
* TestEmptyBranch's docstring starts with a space.
Aside from that, one question: What about using 403 Forbidden for hidden branches instead of 404 Not Found? Obviously it'd reveal their existence, but it's also more true to a setting named "serve_http = False". Sort of. Maybe. :D
Adrian Wilkins (adrian-wilkins) wrote : | # |
> What about using 403 Forbidden for hidden
> branches instead of 404 Not Found? Obviously it'd reveal their existence, but
> it's also more true to a setting named "serve_http = False". Sort of. Maybe.
> :D
I've noted that some servers go the other way, and pitch a 403 for requests to non-existent branches as well. This is either "more secure" or "of dubious helpfulness", depending on your point of view.
Matt Nordhoff (mnordhoff) wrote : | # |
> > What about using 403 Forbidden for hidden
> > branches instead of 404 Not Found? Obviously it'd reveal their existence,
> but
> > it's also more true to a setting named "serve_http = False". Sort of. Maybe.
> > :D
>
> I've noted that some servers go the other way, and pitch a 403 for requests to
> non-existent branches as well. This is either "more secure" or "of dubious
> helpfulness", depending on your point of view.
For truly non-existent branches, I vote 404.
For hidden branches, IMO 403 is correct, but I can accept 404 for the privacy aspect.
Anyway, what do you want to do here? I'm okay either way. :)
Matt Nordhoff (mnordhoff) wrote : | # |
I approve, pending the 403 vs. 404 bikeshed I started, but someone more knowledgeable than me should verify that you didn't miss any entry points.
Serving .bzr is broken -- see lp:~jelmer/loggerhead/fix-bzrserve or lp:~mnordhoff/loggerhead/380026-fix-serving-branches, but there are conflicts between them and this branch, and I'd prefer that you fix them. I could probably handle it myself, but it'd mostly be guesswork, trying random things until it stopped spewing 500 Internal Server Errors.
- 361. By Martin Albisetti
-
Fixed whitespace and other trivial bits from the review
Martin Albisetti (beuno) wrote : | # |
> * The copyright headers tend to have 2 spaces between "2009" and "Canonical".
>
> * TestEmptyBranch's docstring starts with a space.
Done.
> Aside from that, one question: What about using 403 Forbidden for hidden
> branches instead of 404 Not Found? Obviously it'd reveal their existence, but
> it's also more true to a setting named "serve_http = False". Sort of. Maybe.
> :D
I chose 404 because it gives out less about what's available. I feel that if we spit out a 403, there has to be some sort of ACL or way of viewing them, when there actually isn't.
Matt Nordhoff (mnordhoff) wrote : | # |
> I approve, pending the 403 vs. 404 bikeshed I started, but someone more
> knowledgeable than me should verify that you didn't miss any entry points.
>
> Serving .bzr is broken -- see lp:~jelmer/loggerhead/fix-bzrserve or
> lp:~mnordhoff/loggerhead/380026-fix-serving-branches, but there are conflicts
> between them and this branch, and I'd prefer that you fix them. I could
> probably handle it myself, but it'd mostly be guesswork, trying random things
> until it stopped spewing 500 Internal Server Errors.
Also: I think you should use ConfigObj's as_bool method instead of "== 'False'".
Matt Nordhoff (mnordhoff) wrote : | # |
> Serving .bzr is broken -- see lp:~jelmer/loggerhead/fix-bzrserve or
> lp:~mnordhoff/loggerhead/380026-fix-serving-branches, but there are conflicts
> between them and this branch, and I'd prefer that you fix them. I could
> probably handle it myself, but it'd mostly be guesswork, trying random things
> until it stopped spewing 500 Internal Server Errors.
Those branches have now landed, FYI.
- 362. By Martin Albisetti
-
Merge from trunk and fix conflict by refactoring the code
Martin Albisetti (beuno) wrote : | # |
Ok, merged with trunk and resolved conflicts by refactoring.
All tests pass :)
Martin Albisetti (beuno) wrote : | # |
> Also: I think you should use ConfigObj's as_bool method instead of "==
> 'False'".
Would you be so kind as to point me to an example of this?
Matt Nordhoff (mnordhoff) wrote : | # |
I just noticed that a few tabs got introduced into the code:
$ ack-grep --python '\t'
loggerhead/
111: bzrdir = BzrDir.
112: self.transport.
113: branch = bzrdir.
114: if branch.
115: raise httpexceptions.
117: return
loggerhead/
75: if b.get_config(
Matt Nordhoff (mnordhoff) wrote : | # |
Martin Albisetti wrote:
> Ok, merged with trunk and resolved conflicts by refactoring.
> All tests pass :)
I fixed the tabs and a couple other trivial things in
lp:~mnordhoff/loggerhead/serve-config.
However, now there's a different issue: When serving branches on a
remote transport, trying to access .bzr/ results in a
TooManyConcurre
BzrDir.
E.g.:
serve-config$ bzr serve --directory .. &
serve-config$ ./serve-branches bzr://localhost/ &
serve-config$ bzr log -r -1 http://
Matt Nordhoff (mnordhoff) wrote : | # |
Martin Albisetti wrote:
>> Also: I think you should use ConfigObj's as_bool method instead of "==
>> 'False'".
>
> Would you be so kind as to point me to an example of this?
Sorry, I dunno. When going through Bazaar's configuration system, I'm
not sure if it's possible to use it.
- 363. By Martin Albisetti
-
Merge in Peng's tab fixes
Michael Hudson-Doyle (mwhudson) wrote : | # |
I guess this is bb:comment... two points:
1) I'm not sure what checking in branch.py and in transport.py really gains you -- I think just checking in branch.py would be OK?
2) '== "False"' as a condition check is pretty icky, I think at least 'false' should be accepted too. It's unfortunate that bzrlib doesn't let you at the as_bool method of configobj. Perhaps we can just paste in a version of that as a standalone function? And file a bug on bzrlib.
Let's chat about these points on IRC sometime.
Martin Albisetti (beuno) wrote : | # |
> 1) I'm not sure what checking in branch.py and in transport.py really gains
> you -- I think just checking in branch.py would be OK?
Checking in transport.py blocks serving branches as well I think.
> 2) '== "False"' as a condition check is pretty icky, I think at least 'false'
> should be accepted too. It's unfortunate that bzrlib doesn't let you at the
> as_bool method of configobj. Perhaps we can just paste in a version of that
> as a standalone function? And file a bug on bzrlib.
>
> Let's chat about these points on IRC sometime.
Sure, ping me.
- 364. By Martin Albisetti
-
Merge from trunk
- 365. By Martin Albisetti
-
Add deprecation warning to start-loggerhead
Michael Hudson-Doyle (mwhudson) wrote : | # |
Land it, let's deal with the fallout later :)
Preview Diff
1 | === modified file 'NEWS' | |||
2 | --- NEWS 2009-05-17 11:10:38 +0000 | |||
3 | +++ NEWS 2009-05-27 12:51:51 +0000 | |||
4 | @@ -115,6 +115,10 @@ | |||
5 | 115 | 115 | ||
6 | 116 | - Fix 'bzr serve --http' errors. (Matt Nordhoff, #377551) | 116 | - Fix 'bzr serve --http' errors. (Matt Nordhoff, #377551) |
7 | 117 | 117 | ||
8 | 118 | - Added the option to hide branches by setting http_serve = False | ||
9 | 119 | in locations.conf (Martin Albisetti) | ||
10 | 120 | |||
11 | 121 | |||
12 | 118 | 1.10 [22Dec2008] | 122 | 1.10 [22Dec2008] |
13 | 119 | --------------- | 123 | --------------- |
14 | 120 | 124 | ||
15 | 121 | 125 | ||
16 | === renamed file 'README.txt' => 'README' | |||
17 | --- README.txt 2009-03-17 22:31:42 +0000 | |||
18 | +++ README 2009-05-27 12:52:49 +0000 | |||
19 | @@ -1,7 +1,7 @@ | |||
20 | 1 | LOGGERHEAD | 1 | LOGGERHEAD |
21 | 2 | ========== | 2 | ========== |
22 | 3 | 3 | ||
24 | 4 | [ Version 1.6 for Bazaar 1.6 ] | 4 | [ Version 1.10 for Bazaar 1.6 ] |
25 | 5 | 5 | ||
26 | 6 | Loggerhead is a web viewer for Bazaar branches. It can be used to | 6 | Loggerhead is a web viewer for Bazaar branches. It can be used to |
27 | 7 | navigate a branch history, annotate files, perform searches... all the | 7 | navigate a branch history, annotate files, perform searches... all the |
28 | @@ -63,31 +63,14 @@ | |||
29 | 63 | USING A CONFIG FILE | 63 | USING A CONFIG FILE |
30 | 64 | ------------------- | 64 | ------------------- |
31 | 65 | 65 | ||
57 | 66 | Previous versions of Loggerhead read their configuration from a config | 66 | To hide branches from being displayed, add to ``~/.bazaar/locations.conf``, |
58 | 67 | file. This mode of operation is still supported by the | 67 | under the branch's section: |
59 | 68 | 'start-loggerhead' script. A 'loggerhead.conf.example' file is | 68 | |
60 | 69 | included in the source which has comments explaining the various | 69 | [/path/to/branch] |
61 | 70 | options. | 70 | http_serve = False |
62 | 71 | 71 | ||
63 | 72 | Loggerhead can then be started by running:: | 72 | |
64 | 73 | 73 | More configuration options to come soon. | |
40 | 74 | $ ./start-loggerhead | ||
41 | 75 | |||
42 | 76 | This will run loggerhead in the background, listening on port 8080 by | ||
43 | 77 | default. | ||
44 | 78 | |||
45 | 79 | To stop Loggerhead, run:: | ||
46 | 80 | |||
47 | 81 | $ ./stop-loggerhead | ||
48 | 82 | |||
49 | 83 | In the configuration file you can configure projects, and branches per | ||
50 | 84 | project. The idea is that you could be publishing several (possibly | ||
51 | 85 | unrelated) projects through the same loggerhead instance, and several | ||
52 | 86 | branches for the same project. See the "loggerhead.conf.example" file | ||
53 | 87 | included with the source. | ||
54 | 88 | |||
55 | 89 | A debug and access log are stored in the logs/ folder, relative to | ||
56 | 90 | the location of the start-loggerhead script. | ||
65 | 91 | 74 | ||
66 | 92 | 75 | ||
67 | 93 | SERVING LOGGERHEAD FROM BEHIND APACHE | 76 | SERVING LOGGERHEAD FROM BEHIND APACHE |
68 | @@ -107,13 +90,14 @@ | |||
69 | 107 | run behind a proxy at the root of a site, but if you're running it at | 90 | run behind a proxy at the root of a site, but if you're running it at |
70 | 108 | some path into the site, you'll need to specify is using '--prefix=/some_path'. | 91 | some path into the site, you'll need to specify is using '--prefix=/some_path'. |
71 | 109 | 92 | ||
79 | 110 | FILES CHANGED CACHE | 93 | |
80 | 111 | ------------------- | 94 | SEARCH |
81 | 112 | 95 | ------ | |
82 | 113 | To speed up the display of the changelog view for large trees, | 96 | |
83 | 114 | loggerhead can be configured to cache the files changes between | 97 | Search is currently supported by using the bzr-search plugin (available |
84 | 115 | revisions. Set the 'cachepath' value in the config file. | 98 | at: ``https://launchpad.net/bzr-search`` |
85 | 116 | 99 | You need to have the plugin installed and each branch indexed to allow | |
86 | 100 | searching on branches. | ||
87 | 117 | 101 | ||
88 | 118 | SUPPORT | 102 | SUPPORT |
89 | 119 | ------- | 103 | ------- |
90 | 120 | 104 | ||
91 | === modified file 'loggerhead/apps/branch.py' | |||
92 | --- loggerhead/apps/branch.py 2009-05-13 11:34:09 +0000 | |||
93 | +++ loggerhead/apps/branch.py 2009-05-27 09:55:41 +0000 | |||
94 | @@ -1,3 +1,19 @@ | |||
95 | 1 | # Copyright (C) 2008, 2009 Canonical Ltd. | ||
96 | 2 | # | ||
97 | 3 | # This program is free software; you can redistribute it and/or modify | ||
98 | 4 | # it under the terms of the GNU General Public License as published by | ||
99 | 5 | # the Free Software Foundation; either version 2 of the License, or | ||
100 | 6 | # (at your option) any later version. | ||
101 | 7 | # | ||
102 | 8 | # This program is distributed in the hope that it will be useful, | ||
103 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
104 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
105 | 11 | # GNU General Public License for more details. | ||
106 | 12 | # | ||
107 | 13 | # You should have received a copy of the GNU General Public License | ||
108 | 14 | # along with this program; if not, write to the Free Software | ||
109 | 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
110 | 16 | # | ||
111 | 1 | """The WSGI application for serving a Bazaar branch.""" | 17 | """The WSGI application for serving a Bazaar branch.""" |
112 | 2 | 18 | ||
113 | 3 | import logging | 19 | import logging |
114 | @@ -113,6 +129,10 @@ | |||
115 | 113 | return self.branch.get_config().get_user_option('public_branch') | 129 | return self.branch.get_config().get_user_option('public_branch') |
116 | 114 | 130 | ||
117 | 115 | def app(self, environ, start_response): | 131 | def app(self, environ, start_response): |
118 | 132 | # Check again if the branch is blocked from being served, this is | ||
119 | 133 | # mostly for tests. It's already checked in apps/transport.py | ||
120 | 134 | if self.branch.get_config().get_user_option('http_serve') == 'False': | ||
121 | 135 | raise httpexceptions.HTTPNotFound() | ||
122 | 116 | self._url_base = environ['SCRIPT_NAME'] | 136 | self._url_base = environ['SCRIPT_NAME'] |
123 | 117 | self._static_url_base = environ.get('loggerhead.static.url') | 137 | self._static_url_base = environ.get('loggerhead.static.url') |
124 | 118 | if self._static_url_base is None: | 138 | if self._static_url_base is None: |
125 | 119 | 139 | ||
126 | === modified file 'loggerhead/apps/transport.py' | |||
127 | --- loggerhead/apps/transport.py 2009-05-04 20:28:50 +0000 | |||
128 | +++ loggerhead/apps/transport.py 2009-05-27 09:55:41 +0000 | |||
129 | @@ -1,6 +1,23 @@ | |||
130 | 1 | # Copyright (C) 2008, 2009 Canonical Ltd. | ||
131 | 2 | # | ||
132 | 3 | # This program is free software; you can redistribute it and/or modify | ||
133 | 4 | # it under the terms of the GNU General Public License as published by | ||
134 | 5 | # the Free Software Foundation; either version 2 of the License, or | ||
135 | 6 | # (at your option) any later version. | ||
136 | 7 | # | ||
137 | 8 | # This program is distributed in the hope that it will be useful, | ||
138 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
139 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
140 | 11 | # GNU General Public License for more details. | ||
141 | 12 | # | ||
142 | 13 | # You should have received a copy of the GNU General Public License | ||
143 | 14 | # along with this program; if not, write to the Free Software | ||
144 | 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
145 | 16 | # | ||
146 | 1 | """Serve branches at urls that mimic a transport's file system layout.""" | 17 | """Serve branches at urls that mimic a transport's file system layout.""" |
147 | 2 | 18 | ||
148 | 3 | from bzrlib import branch, errors, lru_cache, urlutils | 19 | from bzrlib import branch, errors, lru_cache, urlutils |
149 | 20 | from bzrlib.bzrdir import BzrDir | ||
150 | 4 | 21 | ||
151 | 5 | from paste.request import path_info_pop | 22 | from paste.request import path_info_pop |
152 | 6 | from paste import httpexceptions | 23 | from paste import httpexceptions |
153 | @@ -63,7 +80,10 @@ | |||
154 | 63 | raise httpexceptions.HTTPNotFound() | 80 | raise httpexceptions.HTTPNotFound() |
155 | 64 | return self.app_for_non_branch(environ)(environ, start_response) | 81 | return self.app_for_non_branch(environ)(environ, start_response) |
156 | 65 | else: | 82 | else: |
158 | 66 | return self.app_for_branch(b)(environ, start_response) | 83 | if b.get_config().get_user_option('http_serve') == 'False': |
159 | 84 | raise httpexceptions.HTTPNotFound() | ||
160 | 85 | else: | ||
161 | 86 | return self.app_for_branch(b)(environ, start_response) | ||
162 | 67 | 87 | ||
163 | 68 | 88 | ||
164 | 69 | class BranchesFromTransportRoot(object): | 89 | class BranchesFromTransportRoot(object): |
165 | @@ -82,6 +102,14 @@ | |||
166 | 82 | elif environ['PATH_INFO'] == '/favicon.ico': | 102 | elif environ['PATH_INFO'] == '/favicon.ico': |
167 | 83 | return favicon_app(environ, start_response) | 103 | return favicon_app(environ, start_response) |
168 | 84 | elif '/.bzr/' in environ['PATH_INFO']: | 104 | elif '/.bzr/' in environ['PATH_INFO']: |
169 | 105 | try: | ||
170 | 106 | bzrdir = BzrDir.open_containing_from_transport( | ||
171 | 107 | self.transport.clone(environ['PATH_INFO'])) | ||
172 | 108 | branch = bzrdir.open_branch() | ||
173 | 109 | if branch.get_config().get_user_option('http_serve') == 'False': | ||
174 | 110 | raise httpexceptions.HTTPNotFound() | ||
175 | 111 | except errors.NotBranchError: | ||
176 | 112 | pass | ||
177 | 85 | app = urlparser.make_static(None, self.transport) | 113 | app = urlparser.make_static(None, self.transport) |
178 | 86 | return app(environ, start_response) | 114 | return app(environ, start_response) |
179 | 87 | else: | 115 | else: |
180 | 88 | 116 | ||
181 | === modified file 'loggerhead/controllers/directory_ui.py' | |||
182 | --- loggerhead/controllers/directory_ui.py 2009-05-05 18:37:26 +0000 | |||
183 | +++ loggerhead/controllers/directory_ui.py 2009-05-26 16:21:53 +0000 | |||
184 | @@ -72,6 +72,8 @@ | |||
185 | 72 | for d in listing: | 72 | for d in listing: |
186 | 73 | try: | 73 | try: |
187 | 74 | b = branch.Branch.open_from_transport(self.transport.clone(d)) | 74 | b = branch.Branch.open_from_transport(self.transport.clone(d)) |
188 | 75 | if b.get_config().get_user_option('http_serve') == 'False': | ||
189 | 76 | continue | ||
190 | 75 | except: | 77 | except: |
191 | 76 | if not stat.S_ISDIR(self.transport.stat(d).st_mode): | 78 | if not stat.S_ISDIR(self.transport.stat(d).st_mode): |
192 | 77 | continue | 79 | continue |
193 | 78 | 80 | ||
194 | === modified file 'loggerhead/tests/test_simple.py' | |||
195 | --- loggerhead/tests/test_simple.py 2009-02-18 10:40:22 +0000 | |||
196 | +++ loggerhead/tests/test_simple.py 2009-05-27 12:44:28 +0000 | |||
197 | @@ -1,8 +1,26 @@ | |||
198 | 1 | # Copyright (C) 2008, 2009 Canonical Ltd. | ||
199 | 2 | # | ||
200 | 3 | # This program is free software; you can redistribute it and/or modify | ||
201 | 4 | # it under the terms of the GNU General Public License as published by | ||
202 | 5 | # the Free Software Foundation; either version 2 of the License, or | ||
203 | 6 | # (at your option) any later version. | ||
204 | 7 | # | ||
205 | 8 | # This program is distributed in the hope that it will be useful, | ||
206 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
207 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
208 | 11 | # GNU General Public License for more details. | ||
209 | 12 | # | ||
210 | 13 | # You should have received a copy of the GNU General Public License | ||
211 | 14 | # along with this program; if not, write to the Free Software | ||
212 | 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
213 | 16 | # | ||
214 | 17 | |||
215 | 1 | import cgi | 18 | import cgi |
216 | 2 | import logging | 19 | import logging |
217 | 3 | 20 | ||
218 | 4 | from bzrlib.tests import TestCaseWithTransport | 21 | from bzrlib.tests import TestCaseWithTransport |
219 | 5 | from bzrlib.util.configobj.configobj import ConfigObj | 22 | from bzrlib.util.configobj.configobj import ConfigObj |
220 | 23 | from bzrlib import config | ||
221 | 6 | 24 | ||
222 | 7 | from loggerhead.apps.branch import BranchWSGIApp | 25 | from loggerhead.apps.branch import BranchWSGIApp |
223 | 8 | from paste.fixture import TestApp | 26 | from paste.fixture import TestApp |
224 | @@ -103,6 +121,7 @@ | |||
225 | 103 | 121 | ||
226 | 104 | 122 | ||
227 | 105 | class TestEmptyBranch(BasicTests): | 123 | class TestEmptyBranch(BasicTests): |
228 | 124 | """ Test that an empty branch doesn't break""" | ||
229 | 106 | 125 | ||
230 | 107 | def setUp(self): | 126 | def setUp(self): |
231 | 108 | BasicTests.setUp(self) | 127 | BasicTests.setUp(self) |
232 | @@ -118,3 +137,22 @@ | |||
233 | 118 | res = app.get('/files') | 137 | res = app.get('/files') |
234 | 119 | res.mustcontain('No revisions!') | 138 | res.mustcontain('No revisions!') |
235 | 120 | 139 | ||
236 | 140 | |||
237 | 141 | class TestHiddenBranch(BasicTests): | ||
238 | 142 | """ | ||
239 | 143 | Test that hidden branches aren't shown | ||
240 | 144 | FIXME: not tested that it doesn't show up on listings | ||
241 | 145 | """ | ||
242 | 146 | |||
243 | 147 | def setUp(self): | ||
244 | 148 | BasicTests.setUp(self) | ||
245 | 149 | self.createBranch() | ||
246 | 150 | locations = config.locations_config_filename() | ||
247 | 151 | config.ensure_config_dir_exists() | ||
248 | 152 | open(locations, 'wb').write('[%s]\nhttp_serve = False' | ||
249 | 153 | % (self.tree.branch.base,)) | ||
250 | 154 | |||
251 | 155 | def test_no_access(self): | ||
252 | 156 | app = self.setUpLoggerhead() | ||
253 | 157 | res = app.get('/changes', status=404) | ||
254 | 158 |
This branch does the following:
- Allows hiding branches with serve-branches
- Tests it
- Adds some mising copyright headers
- Renames README.txt to README