Question about programming in team, and svn...

Started by
4 comments, last by markr 10 years, 7 months ago

Hi, i've been programming for a long time, but i never actually worked on a project in parallel with someone else yet.

What id like to know is, how does merges work when using source version control? What if i really changed lots of thing in a certain file?

I know the question is pretty vague but im still learning to use SVN and was wondering how it worked.

thx.

Advertisement

In general, some level of collaboration is necessary to avoid doing the same thing.

If several people are working on the same file, normally they'll be doing unrelated things.

Whoever commits first, "wins" and the other person has to do a merge. Doing the merge is not normally particuarly difficult, but it can easily go wrong.

One of the biggest problems is if you have another developer who is a "tinkerer" and randomly changes stuff (e.g: comments, whitespace, random refactoring) not related to his tasks. This creates unnecessary merge work and gives other developers pain.

If you have such a developer on your project, and you are unable to convince him so stop such behaviour, your project manager should be involved.

There is usually an Interface which tells you what lines of code were changed in a file. You have to see where they made their changes and merge it with yours into one copy, and usually you can see what that final copy looks like as well. It's not hard, you just have to be careful when doing it because you can easily leave out someone else's code by accident and they'll have to either redo it, or revert back.

The thing to remmember is that you always update your code to what is in the reposity before committing. If you update your code and it doesn't work then you can fix it before committing. The key is that broken code should never be committed. Even if you change hundreds of lines in hundreds of files and you have a dozen other people working on the same project (my situation this week), it shouldn't be a problem.

The biggest problem I find is when you have two or more teams working on feature branches that then need to be merged back into trunk. This is when it can be a ball ache.

The tinkerer problem can be approached with extremely strict code reformatting (e.g. no extra blank lines anywhere) before commits (Subversion offers "pre-commit hooks" that can run appropriate tools) and with deliberate campaigns of single-developer cleanup and refactoring before large multi-developer work. Both techniques limit merging to substantial code differences in the least possible number of source files.

Omae Wa Mou Shindeiru

The tinkerer problem cannot be solved technically, it's something which has to be done culturally within the team.

Not only is "tinkering" highly annoying for other developers who have to tolerate merge conflicts, it's actively a problem because tinkering creates bugs.

Only when you have a culture of "if it ain't broke, don't fix it", can the tinkering be prevented.

I prefer the matra "Even if it is broke, still don't fix it until we have a bug report which has been triaged and scheduled into the release you're actually working on". Occasionally people fix bugs by accident though :)

This topic is closed to new replies.

Advertisement