0

I am not terribly familiar with CVS, but at my work I have a project in CVS that is shaped like this:

------A-------B  D         Main branch
      |
      |----------C         My branch

The project at tag A works. At tag B, it does not, so A is in production. This was all done years ago. I come along and want to make changes to A, but I don't know much about B, and since I don't want to touch it, I make a branch. At C, I have decided that my changes are important, and B is irrelevant. I want whatever is at C to sit at D on the main branch, and everything from A to B to be ignored.

Someone at my work suggested that I copy, via the OS, the contents of my branch over the contents of the main branch, but then said it breaks the history and I should ask Stack Overflow for a better solution first.

I'm doing this all in Eclipse, so my idea was to open A in the workspace, merge C into it, and commit the result to the head, prioritizing my side for each and every difference, to get D. However, I'm afraid that the merge from AC to D mightn't do what I expect, and I don't want to break things.

My question is: Will this do what I expect it to do? If not, what is a safer way to do this than my co-worker's suggestion?

AlbeyAmakiir
  • 2,217
  • 6
  • 25
  • 48

3 Answers3

0

I prefer to use WinCVS if I have to use CVS at all. Some of our legacy stuff uses CVS and it's a pain.

You merge back into the main branch exactly the same way as SVN, but it just looks a lot more complicated. See if WinCVS makes it easier and let me know. Don't do the copy & repost though, that's a really bad approach.

Michael
  • 1,014
  • 1
  • 8
  • 23
  • I don't see this as answering the question. First, the question is about Eclipse, so "use something else" isn't really a valid answer. And second, "It's exactly the same as SVN" only helps if you know how SVN does it, which I don't. Perhaps I should have specified that I'm fairly inexperienced with version control systems in general. My experience is update and commit and that's it. But, even if that wasn't the case, any one else who finds this question may be in that situation. – AlbeyAmakiir Aug 09 '12 at 04:08
  • No worries and a fair response. I was suggesting another client as I don't feel that Eclipse's integrated CVS handles everything in the best way possible. So, to relieve you of pains, I suggested a different approach :) You don't have to take it at all. If you're not familiar with version control, that comment won't help; you're right. I'd suggest getting someone else in the office to help you then, as it might be more harmful if you experiment with it. SVN is different to CVS in mechanics, but has many similar concepts; hence my comment. Different under hood & on surface, concepts same. – Michael Aug 09 '12 at 04:24
0

http://www.eclipse.org/articles/article.php?file=Article-BranchingWithEclipseAndCVS/article2.html briefly shows the CVS Merge function. You'll want to find the tag that represents the point where you diverged from HEAD to make use of this.

nitind
  • 19,089
  • 4
  • 34
  • 43
  • Actually, I don't want to synchronise the two branches, I want to wipe out the changes in the main branch and replace it with my branch. Also, reading the documentation has gotten me as far as coming up with a solution, but I'm afraid that it will not work and cause more harm than good. I want someone to tell me if the solution I have come up with will do what I expect. I'll edit the question to highlight this, I think. – AlbeyAmakiir Aug 09 '12 at 06:47
0

Turns out, no, it won't do what I expect. Merging C to A works as expected, but committing AC over B does not, as I am working under the A tag, not the HEAD tag (B), and committing only changes the older tag.

Instead of the proposed method, it should be done in the opposite order, or all at once. The HEAD should be reverted to A, and then the branch can be merged, or you can do them at the same time. CVS in Eclipse doesn't have an easy way to do this cleanly, but it does have an annoying way to do it cleanly:

  • Open the HEAD in your workspace.
  • Right-Click the project -> Compare With -> Another Branch or Version...
  • Choose the point where the branch splits (A) or the end of the branch you want to replace the HEAD with (C).
  • The Synchronise view will show you every file that is different between the two versions.
  • For every file that is different, go back to the Package Explorer view and Right-Click -> History... (Not "Another Branch or Version..." because then you'll be working with multiple tags at once, and commits will go to different places). Then choose the tag that contains the version of the file you want to keep (A or C, depending on what you're comparing with).
  • Once there are no remaining differences, commit.

If you compared with C, both branches are in the same state. You're done. D will have what you want.

Instead, if you compared with A, you can now merge C onto the HEAD. Once you commit again, D will have what you want.

AlbeyAmakiir
  • 2,217
  • 6
  • 25
  • 48