Merge lp://staging/~parthm/bzr/300062-invalid-pattern-warnings into lp://staging/bzr
Status: | Rejected | ||||
---|---|---|---|---|---|
Rejected by: | Robert Collins | ||||
Proposed branch: | lp://staging/~parthm/bzr/300062-invalid-pattern-warnings | ||||
Merge into: | lp://staging/bzr | ||||
Diff against target: |
680 lines (+383/-39) 12 files modified
NEWS (+5/-0) bzrlib/builtins.py (+10/-0) bzrlib/errors.py (+1/-1) bzrlib/globbing.py (+143/-28) bzrlib/lazy_regex.py (+6/-6) bzrlib/tests/blackbox/test_add.py (+28/-0) bzrlib/tests/blackbox/test_ignore.py (+32/-0) bzrlib/tests/blackbox/test_ignored.py (+15/-0) bzrlib/tests/blackbox/test_ls.py (+23/-0) bzrlib/tests/blackbox/test_status.py (+69/-0) bzrlib/tests/test_globbing.py (+41/-4) bzrlib/tests/test_ignores.py (+10/-0) |
||||
To merge this branch: | bzr merge lp://staging/~parthm/bzr/300062-invalid-pattern-warnings | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John A Meinel | Needs Fixing | ||
Robert Collins | Pending | ||
bzr-core | Pending | ||
Review via email: mp+26809@code.staging.launchpad.net |
Commit message
Better handling for invalid patterns in .bzrignore and user ignore. ignore command rejects bad patterns passed to it.
Description of the change
=== Fixed Bug #300062 ===
Based on the earlier discussion
https:/
this branch make bzr issue a warning if there are invalid patterns in any ignore file. 'ls', 'add', 'ignore', 'ignored' and 'status' work as expected. Below is a sample interaction of these commands.
[aaa]% cat .bzrignore
RE:*.cpp
foo
[aaa]% ~/src/bzr.
bzr: warning: Skipped invalid pattern argument(s):
RE:[[[[[
bzr: warning: Skipped invalid pattern(s):
RE:*.cpp
Please fix above patterns in ".bzrignore" or "/home/
Bazaar commands will NOT ignore files meant to match above pattern(s).
[aaa]% cat .bzrignore
RE:*.cpp
foo
xyz
pqr
[aaa]%
=======
[aaa]% ~/src/bzr.
M .bzrignore
bzr: warning: Skipped invalid pattern(s):
RE:*.cpp
Please fix above patterns in ".bzrignore" or "/home/
Bazaar commands will NOT ignore files meant to match above pattern(s).
? one.txt
? two.txt
? x
? y
[aaa]% ~/src/bzr.
bzr: warning: Skipped invalid pattern(s):
RE:*.cpp
Please fix above patterns in ".bzrignore" or "/home/
Bazaar commands will NOT ignore files meant to match above pattern(s).
modified:
.bzrignore
unknown:
one.txt
two.txt
x
y
=======
[aaa]% ~/src/bzr.
.bzrignore.~1~
bzr: warning: Skipped invalid pattern(s):
RE:*.cpp
Please fix above patterns in ".bzrignore" or "/home/
Bazaar commands will NOT ignore files meant to match above pattern(s).
[aaa]% ~/src/bzr.
bzr: warning: Skipped invalid pattern(s):
RE:*.cpp
Please fix above patterns in ".bzrignore" or "/home/
Bazaar commands will NOT ignore files meant to match above pattern(s).
one.txt
two.txt
x
y
=======
[aaa]% ~/src/bzr.
.bzrignore.~1~ *~
bzr: warning: Skipped invalid pattern(s):
RE:*.cpp
Please fix above patterns in ".bzrignore" or "/home/
Bazaar commands will NOT ignore files meant to match above pattern(s).
=======
[aaa]% ~/src/bzr.
bzr: warning: Skipped invalid pattern(s):
RE:*.cpp
Please fix above patterns in ".bzrignore" or "/home/
Bazaar commands will NOT ignore files meant to match above pattern(s).
adding one.txt
adding two.txt
adding x
adding y
Unmerged revisions
- 5292. By Parth Malwankar
-
added test for _Pattern
- 5291. By Parth Malwankar
-
cleanup tests.
- 5290. By Parth Malwankar
-
cleanup of pattern categorization code
- 5289. By Parth Malwankar
-
merged in changes from trunk
- 5288. By Parth Malwankar
-
added _PatternType class to categorize patterns.
- 5287. By Parth Malwankar
-
updated NEWS
- 5286. By Parth Malwankar
-
merged in changes from trunk.
- 5285. By Parth Malwankar
-
added invalid patterns tests for 'ignore'
- 5284. By Parth Malwankar
-
added invalid pattern test for ignored.
- 5283. By Parth Malwankar
-
added invalid pattern tests for 'add' and 'ls'
110 + if validp: patterns. append( g.regex_ patterns[ 0])
111 + g = Globster(validp)
112 + new_regex_
^- This seems odd. A comment here saying that we are collapsing the valid requests into a single compiled regex would be useful.
158 +def is_pattern_ valid(pattern) :
^- It seems like it would be nice if this could share the code that determines what translation unit to use. Otherwise it seems likely to get skew if one of them is updated. For example, the proposed 'FixedString' prefix. The fallout is that it would normally work fine, but if someone had a *different* invalid regex, then suddenly it would start causing this one to fail as well.
I don't understand why you changed variables from being private. In lazy_regex you renamed _real_re_compile to real_re_compile, and in globbing you changed _regex_patterns.
It is perfectly fine for *tests* to check private variables, it is good to keep them private so that plugins get a feeling that they may not be stable names.
...
342 + def test_invalid_ pattern_ in_ignore_ file(self) : branch_ and_tree( '.') tree([' file', 'foo.c']) u"*.c\nRE: [\n") # invalid pattern
343 + """Existing invalid patterns should be shown.
344 + """
345 + tree = self.make_
346 + self.build_
347 + f = open('.bzrignore', 'w')
348 + try:
349 + f.write(
350 + finally:
351 + f.close()
^- I think you can simplify this to: tree_contents( [('.bzrignore' , '*.c\nRE:[\n')])
self.build_
It is pretty bad form to write *unicode* strings to f.write() given that in python2 it is an 8-bit request. (It happens to be automatically casting your unicode string down to an ascii string.)
This test might be easier to read if we turned it into a "run_script" test, but that may not be easily available here.
The same comments apply to test_add_ with_invalid_ ignore_ in_global_ ignore and pattern_ in_ignore_ file in the 2 other places.
test_invalid_