[PATCH][Bug 86451]Normalise path separators in ignore patterns

Kent Gibson warthog618 at gmail.com
Fri Mar 2 00:57:03 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



John Arbash Meinel wrote:
>
>
> Thanks for updating your patch. I'd really like to get this in
> 0.15. There are a few small things, though.
>
> ...
>
> v- Your spacing here is a little odd, I think it is better as:
>
> if (len(m) % 2) != 0:
>
Yeah - that was odd.  I hadn't even noticed.  Must be fat fingers.
> Also, while not strictly required, it would be good to have a
> simple docstring. Maybe "check for trailing backslashes in the
> pattern"
>
I thought it was clear enough from the function name and warning.
But if it will help....
>
>
> + +_normalize_re = re.compile(ur'\\(?!x\d\d|\d\d\d|u\d\d\d\d)') + +
>  +def normalize_pattern(pattern): +    """Converts backslashes in
> path patterns to forward slashes. + +    Avoids converting escape
> backslashes. +    """ +    if not pattern.startswith('RE:'): +
> pattern = _normalize_re.sub('/', pattern) +    return
> pattern.rstrip('/')
>
> ^- If I understand correctly, you are allowing backslashes for
> character codes (hex) \x00 or (octal) \000 (unicode decimal)
> \u0000.  There are a few problems, though.
>
> 1) I don't think you need to do this. I'm guessing you
> misunderstood the tests. But the data in .bzrignore is meant to be
> utf-8 data. So non-ascii characters are expected to be present, but
> not escapes.
I understood that at least one of the tests failed without it.
Generally when I make a change and tests fail I assume it is because I
broke the code.
But based on your comments, I think this is because some of the tests
use raw strings when
they should not.
I've fixed those and replaced the regex with a simple replace.

That's a relief.  That there could be escapes in ignore patterns
(other than REs) had me worried.

Updated bundle attached.

Can someone can tell me why the bundle claims I changed a large chunk
of test_regex, when I only dropped the r in the RE lines?
bzr gvimdiff shows I only changed those lines, not the whole block.
What's da diff?

Cheers,
Kent.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFF53ZegoxTFTi1P8QRAtESAJdBNNsgv5B+GN6r42rJia2eIe08AKDPvfvT
PI8kE/f0S7DpD/OsDpLQOQ==
=Hf+u
-----END PGP SIGNATURE-----

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lp86451_b.patch
Type: text/x-patch
Size: 15408 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070302/3b194521/attachment.bin 


More information about the bazaar mailing list