Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent users overwriting each others work in svn

I'm using subversion for version control.

I frequently see instances where commits overwrite each other. In git this is prevented as you cannot push until you have pulled if your local repo is out of date. Is there a similar mechanism in subversion?

e.g.

  1. Bob updates his working copy with svn update. He proceeds to work on some changes to file A over several days.

  2. Meanwhile, Alice update her working copy, and makes a small change to file A, then commits it in the same day.

  3. A day or so later, Bob commits his changes - which won't include Alice's changes to file A - overwriting and removing Alice's changes. When Bob makes his commit, he gets no warning, no conflict or any indication that he needed to update first because the repo has changed.

  4. Bob does not deliberately touch any of the lines of code that Alice changed, but because his working copy does not contain Alice's code when he commits it, the result is that the repo has Bob's changes only, and Alice's have vanished.

Although Bob and Alice both have a process in place that means they are supposed to use svn update before they commit, it seems (to Bob) that svn does not enforce this and Bob frequently forgets.

How can we prevent this?

[Edit] Thanks to everyone who has waded in so far. It looks like you're all saying the same thing - that what I'm describing can't happen. Unfortunately my experience with svn, using different clients, and different versions of svn over several years (on and off) is exactly as described above. It looks like there's a fundamental thing I'm missing in svn to make it prevent committing code when your working copy is out of sync - it's happened too many times for me to believe that svn can prevent it, despite all the answers here. So something is screwy - I need to find out what - does anyone have any suggestions about how the perceived effect described could happen (without Bob deliberately deleting Alice's code and then lying to the world)?

PS: I'm Bob.

like image 804
Hippyjim Avatar asked Jan 10 '23 18:01

Hippyjim


1 Answers

Although Bob and Alice both have a process in place that means they are supposed to use svn update before they commit, there is no technology in place to enforce this and Bob frequently forgets.

That's because there is no technology that can completely protect you from users not paying attention to what they're doing.

Meanwhile, Alice update her working copy, and makes a small change to file A, then commits it in the same day.

A day or so later, Bob commits his changes - which won't include Alice's changes to file A - overwriting and removing Alice's changes.

Bob can't commit without running svn update, and if he's changed things that Alice changed, that will trigger a conflict which Bob has to resolve. If Bob doesn't properly resolve it himself, yes, Alice's work can be lost - but that's a "people" problem, not a technical one. No software can stop Bob from improperly managing that code conflict.

like image 98
alroc Avatar answered Mar 12 '23 01:03

alroc