jQuery in Action, 2nd edition*
The moose likes IDEs, Version Control and other tools and the fly likes cvs committ question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "cvs committ question" Watch "cvs committ question" New topic
Author

cvs committ question

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
1. I check out a file from cvs (get a clean copy)
2. I make change on the file
3. I committ it back to CVS.

Question --- if between step 1) and 3), someone else has committed his change to CVS, will my change

a) wipe off the other person's change and put my change

or

b) merge the other person's change with my change ?

How to make sure that, wen I committ my change, I don't miss any changes other people have made during the period I hold this file ?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
It will in fact

c) raise an error and refuse to commit your changes until you did a cvs update first.

That update will merge the remote changes into your local copy. Before you commit the merge, you should first check whether the merge broke anything - ideally by running your suite of automated unit tests.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

Ilja, re you sure? thought the update would cuss you out with a "local file conflicts with archive, please move it out of the way" message, and you had to to the merge manually. I'm pretty sure about the manual merge part. I've got scars. And even the IDEs will only do automatic merging if there's no outright conflict - CVS itself isn't that smart.

BTW, CVS and SVN are different from most commercial SCM's. Commercial products like PVCS actually lock a file when you check it out for update and don't unlock it until you release it. So no one else gets a read/write copy of the file if it's locked. CVS was designed different because people on the other side of the planet might start work on a file, decide to go on a world cruise or something and forget to check it back in. So there's no locking, just conflict detection.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Tim Holloway:
Ilja, re you sure?


Yes, I am.

thought the update would cuss you out with a "local file conflicts with archive, please move it out of the way" message, and you had to to the merge manually.


With CVS, that only happens when you try to check out a file that already exists locally, but the local version wasn't yet under version control. SVN is at least as smart - perhaps even smarter, don't have that much experience with it.


I'm pretty sure about the manual merge part. I've got scars. And even the IDEs will only do automatic merging if there's no outright conflict - CVS itself isn't that smart.


I'm pretty sure that you are wrong. I have seen CVS do automatic merges outside of the IDE. And if there is a conflict, it will actually create a version of the file that contains both versions of the conflict, and that you can edit to remove the conflict. IDEs are even better for that, of course.

BTW, CVS and SVN are different from most commercial SCM's. Commercial products like PVCS actually lock a file when you check it out for update and don't unlock it until you release it.


CVS can be configured to do that, too, although I've heard that it's not as well supported. (Look for the edit/unedit commands).

I don't know about PVCS, but many commercial SCMs also support optimistic locking like CVS and SVN. For example, VSS can be configured that way, although it comes preconfigured with pessimistic locking.

CVS was designed different because people on the other side of the planet might start work on a file, decide to go on a world cruise or something and forget to check it back in.


I wonder where you get that from.

I find that even if you don't go at a world cruise, the possibility to work concurrently at the same file actually is quite nice, and only quite seldomly leads to problems.
Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
so, a follow-up question --- Do you think the idea of PVCS' locking a file until it is released by one person is good ? i.e. at any time, only one person can lock the file and work on it ? It seems this avoids any problem that can be caused by merge, but it seems too strict. What if this guy goes to vacation and forget unlocking ???
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Raj Ohadi:
so, a follow-up question --- Do you think the idea of PVCS' locking a file until it is released by one person is good ? i.e. at any time, only one person can lock the file and work on it ? It seems this avoids any problem that can be caused by merge, but it seems too strict. What if this guy goes to vacation and forget unlocking ???


I've worked with pessimistic locking (that's what it is called) for a few weeks some years ago. Finally, we switched VSS to optimistic locking, which worked much better for us - even though VSS' support for it is less than optimal (or at least was at that time).

With other words, I will likely never use pessimistic locking again, unless forced to.
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
I agree with Ilja, I really prefer the not-locking strategy, it seems a little strange at first but really works much better. The only exception is when you version a lot of binary files (Word documents) as they often can not be merged.
If you are looking for a new versioning system I would take a close look at Subversion (SVN) as it is considered a successor of CVS. Subversion allows you to use both strategies together where you lock for example only the binary files (I don't know if CVS can do that).

(Ilja, currently I'm forced to use CVS in Eclipse. When I have a conflict (modified a file with a more recent version in the repository), CVS does not merge automatically it only does not allow a commit. SVN does as long as the differences are in different parts of the file. The behaviour you describe is actually the same as SVN does)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

The advantage of locking is that there's never a need to merge. Merging is a ROYAL pain. I just recently had to reconcile a bunch of changes between 2 conflicting Subversion versions and no sir, I didn't like it.

If you don't like my "world cruise" idea, consider this: CVS is/was the version control choice for open-source projects. Open-source projects are historically volunteer labor and the work is done whenever it's convenient to the various authors. World cruises notwithstanding, a large project may have modules of interest to multiple people, but some of those people end up distracted by their day jobs, have medical emergencies, lose interest, etc. So the alternative is to have an archive managere unlock it (assuming he/she isn't unavailable) or to operate lock-free and let the various parties reconcile the conflicts among themselves.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by bart zagers:

(Ilja, currently I'm forced to use CVS in Eclipse. When I have a conflict (modified a file with a more recent version in the repository), CVS does not merge automatically it only does not allow a commit. SVN does as long as the differences are in different parts of the file. The behaviour you describe is actually the same as SVN does)


We are also using CVS + Eclipse at work. And I know for certain that most of the conflicts we encounter get automatically merged by CVS during updates.
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
Hmm, thanks, that means I'm doing something wrong.
I will have to investigate what exactly (I assumed it just worked like that).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cvs committ question