How well does Python's whitespace dependency interact with source control with regards to merging?

StackOverflow https://stackoverflow.com/questions/119399

Question

I'm wondering if the need to alter the indentation of code to adjust the nesting has any adverse effects on merging changes in a system like SVN.

Was it helpful?

Solution

It works fine so long as everyone on the project has agreed to use the same whitespace style (spaces or tabs).

But I've seen cases where a developer has converted an entire file from spaces to tabs (I think Eclipse had that as a feature, bound to Ctrl+Tab!), which makes spotting diffs near impossible.

OTHER TIPS

I've used python with SVN and Mercurial, and have no hassles merging.

It all depends on how the diffing is done - and I suspect that it is character-by-character, which would notice the difference between one level of indent and another.

Generally source control systems merge on a line-by-line basis by default. I have found that merging Python code is no different from merging any other source code that is reasonably indented. If one programmer wraps a block of code in an if statement (indenting the whole block), and another programmer modifies something inside the block, then there will be a merge conflict. Fortunately, the conflict in this case is super easy to resolve.

If you use an external merge tool, then your tool may support more detailed textual merging algorithms that take the above scenario into account automatically.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top