[MERGE] Less bazaar coding style regressions.

Martin Pool mbp at canonical.com
Sat Dec 13 01:23:51 GMT 2008


On 13 Dec 2008, Marius Kruger <amanic at gmail.com> wrote:
> 2008/12/11 Robert Collins <robertc at robertcollins.net>
> 
>     Robert Collins has voted tweak.
>     Status is now: Conditionally approved
> 
>  
> BTW. MartinP suggested a different approach on the mailing list,
> which I'll pursue later. I think this can go in so long to pave the way.
> We can always remove it later if it becomes redundant.

This is ok with me to merge, though I would really like if you change it
to check all source, and we'll strip it out in one go.

> === modified file 'NEWS'
> --- NEWS	2008-12-05 17:26:40 +0000
> +++ NEWS	2008-12-12 23:41:15 +0000
> @@ -37,6 +37,9 @@
>  
>    TESTING:
>  
> +    * ``bzr selftest`` now fails if new trailing white space is added to the
> +      bazaar sources. (Marius Kruger)
> +
>    INTERNALS:
>  
>      * ``KnitVersionedFiles.get_record_stream()`` will now chose a
> 

Please mention here that it's just checked for the pending commit.

It would actually be quite cool to make this into an example of how you
can enforce this from a precommit hook...

>  class TestSourceHelper(TestCase):
>  
>      def source_file_name(self, package):
> @@ -279,6 +332,54 @@
>                '\n\n    %s'
>                % ('\n    '.join(incorrect)))
>  
> +    def test_coding_style(self):
> +        """ Check if bazaar code conforms to some coding style conventions.
> +
> +        Currently we check all .py files for:
> +         * new trailing white space
> +         * new leading tabs
> +         * new long lines (give warning only)
> +         * no newline at end of files
> +        """
> +        bzr_dir = osutils.dirname(bzrlib.__path__[0])
> +        try:
> +            wt = WorkingTree.open(bzr_dir)
> +        except:
> +            raise TestSkipped(
> +                'Could not open bazaar working tree %s'
> +                % bzr_dir)
> +        diff_output = StringIO()
> +        wt.lock_read()
> +        self.log("TEST LOG")

^^ why?

Aside from that it looks good to me, though Robert might like to look
again.

-- 
Martin      <http://launchpad.net/~mbp>



More information about the bazaar mailing list