[MERGE] default user ignores in ~/.bazaar/ignore

Martin Pool mbp at canonical.com
Tue Jul 18 07:38:01 BST 2006


On 12 Jul 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:
> The attached patch changes our default ignore policy, to hopefully bring
> about a nice intermediate. There are several steps to accomplish this:

+1 to the end result and how you got there.

> +def get_user_ignores():
> +    """Get the list of user ignored files, possibly creating it."""
> +    path = config.user_ignore_config_filename()
> +    patterns = USER_DEFAULTS[:]
> +    try:
> +        f = open(path, 'rb')
> +    except (IOError, OSError), e:
> +        if e.errno not in (errno.ENOENT,):
> +            raise

We have in the past had 'getattr(e, 'errno')', in case it was not there.
I don't think that will happen on access to normal local files though --
from memory it was urllib raising an IOError that wasn't...

> +class TestParseIgnoreFile(TestCase):
> +
> +    def test_parse_fancy(self):
> +        ignored = ignores.parse_ignore_file(StringIO(
> +                './rootdir\n'
> +                'randomfile*\n'
> +                'path/from/ro?t\n'
> +                'unicode\xc2\xb5\n' # u'\xb5'.encode('utf8')
> +                'dos\r\n'
> +                '\n' # empty line
> +                '#comment\n'
> +                ' xx \n' # whitespace
> +                ))
> +        self.assertEqual(['./rootdir', 'randomfile*'
> +                          , 'path/from/ro?t'
> +                          , u'unicode\xb5'
> +                          , 'dos'
> +                          , ' xx '], ignored)

It's more consistent with other code and PEP8 to have the commas at the
end of the lines, and one entry per line.  Also there should be a blank
here.

> +
> +
> +def deprecated_list(deprecation_version, variable_name,
> +                    initial_value, extra=None):
> +    """Create a list that warns when modified
> +
> +    :param deprecation_version: something like zero_nine
> +    :param initial_value: The contents of the list
> +    :param variable_name: This allows better warnings to be printed
> +    :param extra: Extra info to print when printing a warning
> +    """

OK you definitely get brownie points for adding a test for this :-)

-- 
Martin




More information about the bazaar mailing list