Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two-way beautifier integration with Mercurial

Tags:

mercurial

We have a very diverse team of developers. Each developer prefers a very different source code indentation and formatting style. Beautifier/pretty printer tools exist that can output in each of these developers' preferred styles. Our code is stored in a Mercurial repository in a standard formatting style, using a commit hook.

However, I would like to go a bit further. Is it possible to beautify the source code into the developer's preferred style when he clones/pulls/updates his workspace? That way, he would see all code in his preferred style. When he/she commits the code gets beautified back into the standard formatting style of the central repository.

Is there a hook I can use to beautify files before being updated/checked out?

How would that work during merging? Can the others files we are merging against also be beautified using a chosen style (as to minimize the amount of conflicts)?

like image 693
Jose Ceale Avatar asked Sep 24 '11 18:09

Jose Ceale


1 Answers

One possible way (in theory) to implement that would be through encode/decode filters, but I don't think it is worth it, because of all the potential side-effects.

It is best to have some kind of format reinforcement in a centralized place, reject any push to a centralized repo if said centralized repo detects code incorrectly formatted.
That reminds the coder to use the "official" (and unique) code format in place for the current project.

like image 114
VonC Avatar answered Sep 29 '22 22:09

VonC