Merge lp:~amanica/bzr/find_bzrdirs-ignore-PermissionDenied-dirs into lp:bzr
| Status: | Merged |
|---|---|
| Merged at revision: | 5320 |
| Proposed branch: | lp:~amanica/bzr/find_bzrdirs-ignore-PermissionDenied-dirs |
| Merge into: | lp:bzr |
| Diff against target: |
130 lines (+50/-6) (has conflicts) 4 files modified
NEWS (+6/-0) bzrlib/bzrdir.py (+2/-3) bzrlib/tests/__init__.py (+4/-2) bzrlib/tests/test_bzrdir.py (+38/-1) Text conflict in NEWS |
| To merge this branch: | bzr merge lp:~amanica/bzr/find_bzrdirs-ignore-PermissionDenied-dirs |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Robert Collins (community) | Needs Fixing on 2010-05-27 | ||
| Andrew Bennetts | 2010-05-10 | Needs Information on 2010-05-20 | |
|
Review via email:
|
|||
Commit Message
find_bzrdirs should ignore dirs that raises PermissionDenied. (Marius Kruger)
Description of the Change
bzrtools' bzr branches crashes if it tries to walk subdirs on which the current user does not have permissions.
So find_bzrdirs should ignore dirs that raises PermissionDenied.
other notes:
* I moved TestCaseWithMem
because I needed it in a non-memory-
I also made it possible to specify a backing_server.
* I used a PathFilteringServer to raise PermissionDenied for arbitrary paths, because chmod is not available on all platforms (on recommendation from Andrew - thanks!).
- 5222. By Marius Kruger <email address hidden> on 2010-05-11
-
qualify find_bzrdirs in NEWS
| Robert Collins (lifeless) wrote : | # |
It might be nice to do a matcher rather than the new complex assert.
-Rob
| Robert Collins (lifeless) wrote : | # |
Let me echo Andrew's plea for more clarity - I'm go to say it with 'Needs Fixing' though - once its more clear we can land this.
If you don't have the time to fix it up, let me know and I'll happily fix the stylistic issues and take my best guess at what the test means - but I'd rather not guess at that. (The style stuff is trivial to do.)
| Marius Kruger (amanica) wrote : | # |
thanks for the reviews, I got most of the things done on the weekend
but ran out of time while looking at the Matcher stuff.
(but can't push it from work now :-( - no outside ssh allowed).
I'm not sure why the test is unclear, it makes a tree like:
foo/bar
baz
(i.e baz is not under foo)
So if foo is inaccessible for whatever reason, it should still return
baz. Thats the problem I'm trying to fix, at the moment it just blows
up in this scenario.
I found some of Robert's blogs about testtools and Matchers etc,
but I didn't find any president for custom Matchers and Mismatches in
bzrlib. I was going to try it out, but it will help if you can point
me in the right direction. Where should I add custom Matchers and
Mismatches ?
| Robert Collins (lifeless) wrote : | # |
bzrlib.
- 5223. By Marius Kruger <email address hidden> on 2010-05-23
-
move make_smart_server back to TestCaseWithMem
oryTransport from TestCaseWithTra nsport as per review - 5224. By Marius Kruger <email address hidden> on 2010-05-23
-
* Tried to improve code docs and NEWS as per review
* _assert_branch_urls => assertBranchUrlsEndsWith
- try to clarify what it does with a more explicit name and code doc
- convert actual_bzrdirs to a list in here for the caller
| Robert Collins (lifeless) wrote : | # |
I'm worried your test may be fragile, now that its a little clearer, it seems likely to me that it depends on filesystem order, and some filesystems return order based on hashing.
You know all the full urls you want, so perhaps just using a set and comparing will be more robust and do the same job?

Thanks for working on this!
review needs-information
Marius Kruger wrote: oryTransport. make_smart_ server TestCaseWithTra nsport, transport- test, and I can't see anything transport- tests.
[...]
> other notes:
> * I moved TestCaseWithMem
> because I needed it in a non-memory-
> that makes this specific to memory-
> I also made it possible to specify a backing_server.
I don't understand this part. TestCaseWithTra nsport is a subclass of oryTransport, so by moving it you've made it available to
TestCaseWithMem
strictly fewer tests, not more.
I think you should move it back. The change to optionally pass a
backing_server is fine.
> === modified file 'NEWS'
> --- NEWS 2010-05-06 06:51:11 +0000
> +++ NEWS 2010-05-10 11:08:28 +0000
> @@ -75,6 +75,8 @@
> * ``bzr selftest`` should not use ui.note() since it's not unicode safe.
> (Vincent Ladeuil, #563997)
>
> +* BzrDir.find_bzrdirs should ignore dirs that raises PermissionDenied. (Marius Kruger)
Put double-backticks around the method name, i.e. ``BzrDir. find_bzrdirs` `,
to format it as code rather than regular text.
> === modified file 'bzrlib/ tests/_ _init__ .py' tests/_ _init__ .py 2010-05-05 14:11:13 +0000 tests/_ _init__ .py 2010-05-10 11:08:28 +0000 bzrdir( relpath, format=format) create_ repository( shared= shared) server( self, path):
> --- bzrlib/
> +++ bzrlib/
> @@ -2408,12 +2408,6 @@
> made_control = self.make_
> return made_control.
>
> - def make_smart_
As stated above, I don't think you should move this.
> === modified file 'bzrlib/ tests/test_ bzrdir. py' permission_ denied_ transport( self, transport, paths): PermissionDenie d(path) PathFilteringSe rver(transport, filter) server. start_server( )
[...]
> + def make_fake_
> + # multiplatform chmod(0000)
> + def filter(path):
> + if path in paths:
> + raise errors.
> + return path
> + path_filter_server = pathfilter.
> + path_filter_
You should do self.addCleanup (path_filter_ server. stop_server) here.
It would be good to add a docstring.
> + path_filter_ transport = pathfilter. PathFilteringTr ansport( server, path_filter_ transport) branch_ urls(self, expect_ url_suffixes, actual_bzrdirs):
> + path_filter_server, '.')
> + return (path_filter_
> +
> + def _assert_
> + "See if each of the actual urls ends with the corresponding suffix"
Style-wise, you should just go ahead and call this assert* rather than double- quoted. We generally
_assert*. And docstrings are always triple-
also use mixedCamelCase for our assertion methods for consistency with
pyunit, but I don't particularly mind if you don't.
“Assert URL” isn't really a meaningful phrase in the way that “assert ends yet-meaningful name for bzrdir_ user_url_ has_suffix” .
with” is. It can be hard to find a concise-
assertion methods... although I see you never pass in more than one
suffix/bzrdir pair at a time in the current code, so you could simplify the
name (and implementation) and call it “assert_
> + self._assert_ branch_ urls([' baz/'], list( BzrDir. find_bzrdirs( path_filter_ transport) ))
> + bzrdir.
e.g. this would be: BzrDir. find_b. ..
bzrdirs = list(bzrdir.