'bzr config pqm' does not find "pqm_email" setting

Bug #670251 reported by Andrew Bennetts
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Vincent Ladeuil

Bug Description

Consider this output:

$ bzr config pqm
$ bzr config pqm_email
locations:
  pqm_email = Canonical PQM <email address hidden>
  pqm_email = Canonical PQM <email address hidden>

This surprised me, especially because “bzr config email” did find those settings that “bzr config pqm” couldn't.

It turns out that 'bzr config' uses fnmatch.translate to convert the MATCHING argument to a regex, but that perhaps surprisingly generates regexes that match \Z (end of string) in this case:

>>> fnmatch.translate('pqm')
'pqm\\Z(?ms)'

It's possible to workaround this by invoking “bzr config '*pqm*'”, but I think the matching could be improved.

Tags: config ui

Related branches

Revision history for this message
John A Meinel (jameinel) wrote :

Just to follow up on this, we are currently using "matching_re.search()" which seems to want to match any possible substring. However "fnmatch.translate" seems to be changing the regexes into "foo$". Which works really oddly.

For example:
$ bzr config location
locations:
  push_location = lp:///~jameinel/bzr
  push_location = lp:~jameinel
branch:
  parent_location = ../../bzr.dev/

But
$ bzr config push

<empty>

There is an argument that "push" != "*push*". However, if that is what we want, then we should be forcing the matching_re to be "push$" and then using "matching_re.match()" rather than search.

Also, from mgz:
(12:28:19 PM) mgz: there was a very similar bug with qbzr on that
(12:28:44 PM) mgz: the fix was adding '*' to the input string.
(12:29:09 PM) mgz: fnmatch.translate behaviour changed at some point.

Vincent Ladeuil (vila)
tags: added: config
Revision history for this message
Martin Packman (gz) wrote :

It's bug 575338 I was thinking of, which is slightly different but a similar fix would work (with John's caveats considered). Deciding what exact behaviour is the hard bit here, changing the match logic is easy.

Vincent Ladeuil (vila)
Changed in bzr:
assignee: nobody → Vincent Ladeuil (vila)
Vincent Ladeuil (vila)
Changed in bzr:
status: Confirmed → In Progress
Revision history for this message
Vincent Ladeuil (vila) wrote :

I went with using pure regexps which avoid the tweaks of the glob provided by the user.

An error will be raised if an invalid '*push' regexp is provided:

$ ./bzr config --all '*push'
bzr: ERROR: Invalid pattern(s) found. "*push" nothing to repeat

Vincent Ladeuil (vila)
Changed in bzr:
milestone: none → 2.3b4
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.