<div dir="ltr">On Mon, Sep 14, 2015 at 3:03 PM, Augie Fackler <span dir="ltr"><<a href="mailto:raf@durin42.com" target="_blank">raf@durin42.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><a href="http://clang.llvm.org/docs/ClangFormat.html" rel="noreferrer" target="_blank">http://clang.llvm.org/docs/ClangFormat.html</a> is a handy tool for having<br>
a machine format your (C/C++/etc) source code rather than having<br>
error-prone humans perform the same tasks. Right now we've got a<br>
handful of rules in check-code for this, but they're not actually<br>
sufficient for all our code to be substantially similar style. I've<br>
created a clang-format file that is *close* to what we already do<br>
(<a href="http://hg.durin42.com/hg-wip/rev/aaeda7971cdb" rel="noreferrer" target="_blank">http://hg.durin42.com/hg-wip/rev/aaeda7971cdb</a>) and have wired up<br>
tests etc that would let us keep files formatted. As a sample of the<br>
result, I've reformatted:<br>
<br>
* manifest.c: <a href="http://hg.durin42.com/hg-wip/rev/ca90a7cff2e1" rel="noreferrer" target="_blank">http://hg.durin42.com/hg-wip/rev/ca90a7cff2e1</a><br>
    This is a nice comprehensive example, and includes working around the<br>
     formatter in a couple spots where Python's macros fool the formatter.<br>
<br>
base85.c: <a href="http://hg.durin42.com/hg-wip/rev/177e9d2e3cc5" rel="noreferrer" target="_blank">http://hg.durin42.com/hg-wip/rev/177e9d2e3cc5</a><br>
    This is a nice example of a file that was in its own style that is trivially<br>
    brought in line with the rest of the codebase.<br>
<br>
Note that the resulting code tweaks check-code's "don't use spaces to<br>
indent" check. My opinion there is that if we start using clang-format<br>
we should just drop anything in check-code that conflicts with<br>
clang-format, since the latter is trivial to apply.<br>
<br>
Thoughts?<br></blockquote><div><br></div><div>I'm a huge fan of having tools do work for me.<br><br></div><div>When I was hacking on some of the C code a few weeks back, I found the style a bit foreign. I would have much preferred to write code in my own style and have clang-format reformat it for me so I didn't have to expend the cognitive load (beyond naming and calling conventions) to conform to Mercurial's standards. <br></div></div><br></div></div>