give a better message for an invalid ignore regexp

Bug #300062 reported by nothing1212 on 2008-11-19
2
Affects Status Importance Assigned to Milestone
Bazaar
Medium
Parth Malwankar

Bug Description

C:\temp\bt>bzr init
Standalone tree (format: pack-0.92)
Location:
  branch root: .

C:\temp\bt>bzr ignore RE:*.cpp
bzr: ERROR: sre_constants.error: nothing to repeat

Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 893, in run_bzr_catch_errors
  File "bzrlib\commands.pyo", line 839, in run_bzr
  File "bzrlib\commands.pyo", line 539, in run_argv_aliases
  File "bzrlib\builtins.pyo", line 2084, in run
  File "bzrlib\globbing.pyo", line 213, in match
  File "bzrlib\lazy_regex.pyo", line 69, in __getattr__
  File "bzrlib\lazy_regex.pyo", line 55, in _compile_and_collapse
  File "bzrlib\lazy_regex.pyo", line 61, in _real_re_compile
  File "re.pyo", line 188, in compile
  File "re.pyo", line 241, in _compile
error: nothing to repeat

bzr 1.9 on python 2.5.2 (win32)
arguments: ['bzr', 'ignore', 'RE:*.cpp']
encoding: 'cp1252', fsenc: 'mbcs', lang: None
plugins:
  bzrtools C:\Program Files\Bazaar\plugins\bzrtools [1.9.1]
  launchpad C:\Program Files\Bazaar\plugins\launchpad [unknown]
  qbzr C:\Program Files\Bazaar\plugins\qbzr [0.9.5]
  svn C:\Program Files\Bazaar\plugins\svn [0.4.14]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

Related branches

description: updated
John A Meinel (jameinel) wrote :

*.cpp

is an invalid regex, I would guess you actually just wanted a glob, which would be "*.cpp".

If you wanted a regex, then you would need "RE:.*\.cpp"

That said, bzr could be a bit better about giving you a single line "Invalid regex: '*.cpp'" or something of the sort.

Changed in bzr:
importance: Undecided → Low
status: New → Triaged

Thank you for the explanation... can I correct the code myself?
If so, how do I get commit access to the code?

On Wed, Nov 19, 2008 at 15:45, John A Meinel <email address hidden> wrote:

> *.cpp
>
> is an invalid regex, I would guess you actually just wanted a glob,
> which would be "*.cpp".
>
> If you wanted a regex, then you would need "RE:.*\.cpp"
>
> That said, bzr could be a bit better about giving you a single line
> "Invalid regex: '*.cpp'" or something of the sort.
>
> ** Changed in: bzr
> Importance: Undecided => Low
> Status: New => Triaged
>
> --
> "bzr ignore RE:*.cpp" just crashed in an empty repo.
> https://bugs.launchpad.net/bugs/300062
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Bazaar Version Control System: Triaged
>
> Bug description:
> C:\temp\bt>bzr init
> Standalone tree (format: pack-0.92)
> Location:
> branch root: .
>
> C:\temp\bt>bzr ignore RE:*.cpp
> bzr: ERROR: sre_constants.error: nothing to repeat
>
> Traceback (most recent call last):
> File "bzrlib\commands.pyo", line 893, in run_bzr_catch_errors
> File "bzrlib\commands.pyo", line 839, in run_bzr
> File "bzrlib\commands.pyo", line 539, in run_argv_aliases
> File "bzrlib\builtins.pyo", line 2084, in run
> File "bzrlib\globbing.pyo", line 213, in match
> File "bzrlib\lazy_regex.pyo", line 69, in __getattr__
> File "bzrlib\lazy_regex.pyo", line 55, in _compile_and_collapse
> File "bzrlib\lazy_regex.pyo", line 61, in _real_re_compile
> File "re.pyo", line 188, in compile
> File "re.pyo", line 241, in _compile
> error: nothing to repeat
>
> bzr 1.9 on python 2.5.2 (win32)
> arguments: ['bzr', 'ignore', 'RE:*.cpp']
> encoding: 'cp1252', fsenc: 'mbcs', lang: None
> plugins:
> bzrtools C:\Program Files\Bazaar\plugins\bzrtools [1.9.1]
> launchpad C:\Program Files\Bazaar\plugins\launchpad [unknown]
> qbzr C:\Program Files\Bazaar\plugins\qbzr [0.9.5]
> svn C:\Program Files\Bazaar\plugins\svn [0.4.14]
> *** Bazaar has encountered an internal error.
> Please report a bug at https://bugs.launchpad.net/bzr/+filebug
> including this traceback, and a description of what you
> were doing when the error occurred.
>

Marius Kruger (amanica) wrote :

2008/11/20 nothing1212 <email address hidden>

> Thank you for the explanation... can I correct the code myself?
> If so, how do I get commit access to the code?

you'll need the dev version which can be obtained like so:
bzr branch http://bazaar-vcs.org/bzr/bzr.dev bzr.dev
(NB its a lot to download, the bzr.dev branch is about 93MB at the moment)

contribution guidlines can be found at:
http://bazaar-vcs.org/BzrDevelopment

Martin Pool (mbp) on 2010-03-19
Changed in bzr:
status: Triaged → Confirmed
Martin Pool (mbp) on 2010-03-19
summary: - "bzr ignore RE:*.cpp" just crashed in an empty repo.
+ give a better message for an invalid ignore regexp
tags: added: easy ignore traceback
Parth Malwankar (parthm) wrote :

This is present on trunk (towards 2.2b4).

[aaa]% bzr ignore "RE:*.cpp"
bzr: ERROR: sre_constants.error: nothing to repeat

Traceback (most recent call last):
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/commands.py", line 911, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/commands.py", line 1109, in run_bzr
    ret = run(*run_argv)
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/commands.py", line 689, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/commands.py", line 704, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/cleanup.py", line 122, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/cleanup.py", line 156, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/builtins.py", line 2723, in run
    if ignored.match(filename):
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/globbing.py", line 213, in match
    match = regex.match(filename)
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/lazy_regex.py", line 69, in __getattr__
    self._compile_and_collapse()
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/lazy_regex.py", line 55, in _compile_and_collapse
    **self._regex_kwargs)
  File "/storage/parth/src/bzr.dev/trunk/bzrlib/lazy_regex.py", line 61, in _real_re_compile
    return _real_re_compile(*args, **kwargs)
  File "/usr/lib/python2.6/re.py", line 190, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.6/re.py", line 245, in _compile
    raise error, v # invalid expression
error: nothing to repeat

You can report this problem to Bazaar's developers by running
    apport-bug /var/crash/bzr.1000.2010-05-30T03:11.crash
if a bug-reporting window does not automatically appear.
[aaa]%

Changed in bzr:
importance: Low → Medium
assignee: nobody → Parth Malwankar (parthm)
status: Confirmed → In Progress
Parth Malwankar (parthm) wrote :

Just to add. The invalid pattern gets added to the .bzrignore file.

Parth Malwankar (parthm) wrote :

Bad ignore pattern now shows a clear message.

[a1]% ~/src/bzr.dev/2.2/bzr ignore "RE:*.cpp" foo
bzr: error: Invalid ignore pattern(s) found.
  RE:*.cpp
bzr: ERROR: Invalid pattern(s) found.
[a1]%

Changed in bzr:
status: In Progress → Fix Released
milestone: none → 2.2.0
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers