Integration of two-way cosmetics with Mercurial

We have a very diverse development team. Each developer prefers a completely different indentation and formatting style of the source code. There are Beautifier / pretty print devices that can be displayed in each of these developers' preferred styles. Our code is stored in the Mercurial repository in a standard formatting style using commit commit.

However, I would like to go a little further. Is it possible to decorate the source code with the developer’s preferred style when he clones / pulls / updates his workspace? Thus, he will see all the code in his preferred style. When he / she commits, the code becomes embellished back to the standard formatting style of the central repository.

Is there a hook that I can use to decorate files before being updated / checked?

How will this work in a merger? Can the files of others that we merge with also be decorated using the chosen style (to minimize the number of conflicts)?

+6
source share
1 answer

One of the possible ways (in theory) to implement this is through code / decode filters , but I don’t think it is worth it, because of all possible side effects.

It is best to have some kind of format reinforcement in a centralized location, to reject any click on a centralized repo if the mentioned centralized repo detects an incorrect code format.
This reminds the encoder to use the “official” (and unique) code format for the current project.

+1
source

Source: https://habr.com/ru/post/897988/


All Articles