<div class="gmail_quote">2009/1/27 John Arbash Meinel <span dir="ltr"><<a href="mailto:john@arbash-meinel.com">john@arbash-meinel.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
John Arbash Meinel has voted tweak.<br>
Status is now: Conditionally approved<br>
Comment:<br>
I think we should merge this, though do we want to wait until right after a release?<br>
<br>
Anyway, I don't see a test change that makes sure all files don't have whitespace, so I presume the only one is the test that makes sure that newly merged changes don't have whitespace, but we should change it to just check everything.</blockquote>
</div><br>The proper test is there, maybe you looked in the wrong diff, see below.<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">2009/1/27 Martin Pool <span dir="ltr"><<a href="mailto:mbp@sourcefrog.net">mbp@sourcefrog.net</a>></span><br>
I think the "band-aid" subject is well chosen, </blockquote><div>thats a quote from jam :)<br><br></div><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
and we might as well<br>
just do it now. I don't think there is any time in the cycle when<br>
it's particularly convenient to get conflicts - but at the moment the<br>
merge queue is relatively small, and we're not immediately close to a<br>release.<br></blockquote>
<br>I also think you should merge this sooner rather than later.<br><br>--<br><b>20090117_2357-bzr.code_style_cleanup.sourcetest-and-doc-updates.diff:</b><br>def test_coding_style(self):<br>- """ Check if bazaar code conforms to some coding style conventions.<br>
+ """Check if bazaar code conforms to some coding style conventions.<br> <br>- Currently we check all .py files for:<br>- * new trailing white space<br>- * new leading tabs<br>
- * new long lines (give warning only)<br>+ Currently we check for:<br>+ * any tab characters<br>+ * trailing white space<br>+ * non-unix newlines<br> * no newline at end of files<br>
+ * lines longer than 79 chars<br>+ (only print how many files and lines are in violation)<br> """<br>- bzr_dir = osutils.dirname(self.get_bzrlib_dir())<br>- try:<br>
- wt = WorkingTree.open(bzr_dir)<br>- except:<br>- raise TestSkipped(<br>- 'Could not open bazaar working tree %s'<br>- % bzr_dir)<br>- diff_output = StringIO()<br>
- wt.lock_read()<br>- try:<br>- new_tree = wt<br>- old_tree = new_tree.basis_tree()<br>-<br>- old_tree.lock_read()<br>- new_tree.lock_read()<br>- try:<br>
- iterator = new_tree.iter_changes(old_tree)<br>- for (file_id, paths, changed_content, versioned, parent,<br>- name, kind, executable) in iterator:<br>- if (changed_content and paths[1].endswith('.py')):<br>
- if kind == ('file', 'file'):<br>- diff_text = diff.DiffText(old_tree, new_tree,<br>- to_file=diff_output,<br>- text_differ=check_coding_style)<br>
- diff_text.diff(file_id, paths[0], paths[1],<br>- kind[0], kind[1])<br>- else:<br>- check_coding_style(name[0], (), name[1],<br>
- new_tree.get_file(file_id).readlines(),<br>- diff_output)<br>- finally:<br>- old_tree.unlock()<br>- new_tree.unlock()<br>
- finally:<br>- wt.unlock()<br>- if len(diff_output.getvalue()) > 0:<br>- self.fail("Unacceptable coding style:\n" + diff_output.getvalue())<br>+ tabs = {}<br>+ trailing_ws = {}<br>
+ illegal_newlines = {}<br>+ long_lines = {}<br>+ no_newline_at_eof = []<br>+ for fname, text in self.get_source_file_contents():<br>+ if not self.is_our_code(fname):<br>+ continue<br>
+ lines = text.splitlines(True)<br>+ last_line_no = len(lines) - 1<br>+ for line_no, line in enumerate(lines):<br>+ if '\t' in line:<br>+ self._push_file(tabs, fname, line_no)<br>
+ if not line.endswith('\n') or line.endswith('\r\n'):<br>+ if line_no != last_line_no: # not no_newline_at_eof<br>+ self._push_file(illegal_newlines, fname, line_no)<br>
+ if line.endswith(' \n'):<br>+ self._push_file(trailing_ws, fname, line_no)<br>+ if len(line) > 80:<br>+ self._push_file(long_lines, fname, line_no)<br>
+ if not lines[-1].endswith('\n'):<br>+ no_newline_at_eof.append(fname)<br>+ problems = []<br>+ if tabs:<br>+ problems.append(self._format_message(tabs,<br>+ 'Tab characters were found in the following source files.'<br>
+ '\nThey should either be replaced by "\\t" or by spaces:'))<br>+ if trailing_ws:<br>+ problems.append(self._format_message(trailing_ws,<br>+ 'Trailing white space was found in the following source files:'<br>
+ ))<br>+ if illegal_newlines:<br>+ problems.append(self._format_message(illegal_newlines,<br>+ 'Non-unix newlines were found in the following source files:'))<br>+ if long_lines:<br>
+ print ("There are %i lines longer than 79 characters in %i files."<br>+ % (sum([len(lines) for f, lines in long_lines.items()]),<br>+ len(long_lines)))<br>+ if no_newline_at_eof:<br>
+ no_newline_at_eof.sort()<br>+ problems.append("The following source files doesn't have a "<br>+ "newline at the end:"<br>+ '\n\n %s'<br>
+ % ('\n '.join(no_newline_at_eof)))<br>+ if problems:<br>+ self.fail('\n\n'.join(problems))<br><br>thanks<br>marius<br>