SVN (Subversive in Eclipse) - compare branch to trunk? - eclipse

I used to work with CVS where it was no problem to compare HEAD to any branch, branch to branch or branch to HEAD. Now on SVN I have some changes on trunk I need to put on a branch, but can't seem to find an option to compare given branch to trunk.
Is it possible to have a branch project in workspace and compare it to trunk?

right-click on the project and choose Compare With, Branch/Tag (this is with subclipse)
APPENDED
What version of the svn client are you using? When I open the Compare With dialog on a project checked out from branch it lets me enter any URL (including trunk) and any revision to compare it to.

Related

Why is the branch not listed in Eclipse-SourceReference for git

I am using Tycho for my Eclipse OSGi projects, and noticed that for project in Git the Eclipse-SourceReferences header doesn't include the branch. I assume it's because I'm not understanding something about Git as to why the branch isn't necessary. But using just the repo URI, the repo path, and the commit Id, how am I assured I also have checked out the correct branch? If that sounds like a silly question .. a branch is a pointer to the tip commit. So what if the commit Id in the SourceReferences header is the tip of multiple branches?
The Eclipse-SourceReferences header is for pointing at the exact sources used to compile that version of the plug-in. It has never held any greater meaning about the original SCM, such as which branch that commit (or CVS tag) came from.

git modifying code on multiple branches using the same eclipse workspace

I kind of feel I am missing something here, but here is the question.
I have a branch A. Work is in progress in this branch. A tag T is created which marks a production release version. Now, a fix has to be done on top of the code in this tag. So I created a branch B out of the tag. The branch would contain stable production code.
My eclipse points to checked-out code in branch A.
Now, I want to make changes to code in branch B. How can I make my eclipse realize that there are 2 different branches and the code is different?
Do I have to clone the branch B and point a new eclipse workspace to it?
Cant I use the same workspace and have 2 different versions of the same file - one from branch A and another from Branch B?
Just checkout branch B in your workspace, make your changes, commit, and then you can checkout again branch A and continue to work on branch A. Eclipse will automatically recognize the content of the other branch
However, you should be aware, that you shouldn't have uncommitted changes in your workspace, when you checkout another branch. Either commit your changes or stash, before checkout.
assuming you have eclipse integrated with your git system, you can use select the project you are working on, and then in the context menu, use "Team->Switch To->New Branch...", and choose branch B.
if you don't have it integrated, you can do so with the following 2 steps.
using the git perspective, in the Git Repositories view, find the icon with the + to perform Add an existing local Git Repository to this view .
in the subsequent dialog, choose the location of your repository.
once it's added, go back to your java perspective, and from there, select the project in git (which you currently have in branch A), and from the context menu, select Team->Share Project

SVN: Synchronize branch with trunk in Eclipse?

I have an SVN branch and a trunk. The trunk changes regularly and the branch doesn't.
Every now and then (let's say once per week) I want to update the local working copy of the branch with the latest changes of the trunk.
Ideally I would want to do this the same way as I do it with the latest version of the branch: with Eclipse : Team->Synchronize, so I can review all changes before updating.
Is this also possible with a different repository (for example : trunk) ?
If not, how do people review the changes before updating then??
I looked at Team->Merge, but this seems to update the changes directly to my working copy, without the possibility to review the changes first (the Preview-function is confusing, I think, and doesn't provide the nice side-by-side view of changes/conflicts that Synchronize has).
The right way to do this is with Merge. Subclipse includes a merge client that makes this easy to do. You are right that it does not give you a true preview, but the way it works is better from a Subversion perspective. The Merge Results view UI is basically the same as the Synchronize view. It lets you easily examine every change that the merge made in your working copy and the Eclipse compare editor that it opens makes it very easy to take out any parts of the change that you do not want in your code before you commit.
The problem with trying to do this from the Synchronize view is that you are then doing the merge yourself using code editors and Subversion has no awareness of what is merged. If you let Subversion first do the merge, then it can update all of its metadata properly and it is perfectly fine for you to then fixup the code to be the way you want it before you commit the results of the merge.
I'd checkout both branch and trunk as a separate eclipse projects into workspace. Then use some merging tool, for example meld to merge changes between them. After merge you can refresh branch in Eclipse and synchronize it with svn repository - now you can review all changes. (it's how I do it, since I do not believe svn eclipse plugin ;))
I agree that it is not really intuitive by design, but Mark is right, you "synchronize" your changes when committing them back to the trunk:
first make sure your local branch is completely synchronized with your repository branch (no changes)
Team -> Merge... your local copy of the branch with the repository trunk
you now have a local version of that merge
you can locally edit this version, make sure tests are working and there are no compiler errors
finally you synchronize your local merged branch version with the repository branch and commit all changes that have been made
besides, the same way you'll merge your branch back into the repository trunk
make sure all changes of your branch are committed to the repository branch
switch to the trunk Team -> Switch...
merge your trunk with your branch Team -> Merge... (Tab 'Reintegrate')
you now have a local version of the merge, you may edit the changes and review them, make sure that you have a working version now
synchronize your local trunk (merged version) with the repository trunk
commit all changes that you want to appear in the trunk
i recommend to commit all changes that you've made locally to your merge, since you've tested them locally. if you commit just a few changes, make sure the repository version is still working then with missing changes

How to properly merge between branches, branched from different versions of trunk?

Our team uses Eclipse to develop a software product, and recently we switched to Subversion to do our source control/version management. At first our team was still committing directly to the trunk as we were new to Subversion's way of source control and things needed to be drawn out still.
At some point I made my first real branch from the trunk to do development for a specific project within our product. Suppose the branch is called DEV_PROJ.
Later as our team knew better how to work with Subversion from Eclipse, I put the team on our first real development branch, not for a specific sub-project but to keep track of different versions. Suppose the branch is called DEV_VERS. Now we are working on that branch and no longer committing directly to the trunk. DEV_VERS was branched from the latest version of the trunk and there have been no commits to the trunk since then.
In between the two branches about two/three months passed and there have been a lot of changes to the trunk before I made the version branch. Now the time has come for me to merge the changes from DEV_PROJ to the DEV_VERS branch to incorporate the project in our new version branch.
What I did first was merge the latest version of the trunk to my DEV_PROJ branch (forward merge?), thinking that would minimize the difference between the two branches while keeping the changes specific to the project.
What I'm trying now and what I'm having problems with is merging the DEV_PROJ to the DEV_VERS branch. Right-click, Team/Merge my DEV_VERS project to start the merge, there are three tabs to choose from: URL, 2 URLs, Reintegrate. As far as I know this is not a reintegration merge, that would be from branch toward the trunk and not between branches that are not directly related. I also don't need to merge two branches towards my branch so I skip 2 URLs tab.
So I choose the first one, URL. As the source I take my project from the DEV_PROJ branch, Revisions: Start from copy, Depth: Working Copy. In a second try, I also chose to Ignore Ancestry. Both tries I push the Preview button to get an overview of what files are target for merging.
What I see is that there are a lot of files that are candidate for merging, that have not been changed in my DEV_PROJ branch. So the (subversion) merging process sees a lot more merging candidates than I had expected. The files I added to the DEV_PROJ branch appear as "Added", but a whole lot of files that I know I didn't change in that branch appear as "Modified" or "Tree Conflict" in the merge overview.
My questions:
Is this the right way to merge between branches? If not can it be done directly using the merge menu (URL, 2URLs, Reintegrate)?
Is my first step (forward merge trunk to DEV_PROJ) the reason why there are merge candidates that were not supposed to be there?
If there is no direct way of merging these branches correctly, then I only see one option. That is merge the DEV_PROJ to the trunk (reintegrate), and then merge the trunk towards the DEV_VERS branch (forward merge). Would this be the right way to do this? If so, is it the only way to do this?
Eclipse: Helios Service Release 2, build: 20110218-0911
SVN server: 1.6.15
Eclipse SVN plugin: SVNKit 1.3.2 (2.2.2.I20100512-1900) // SVN Connector (2.2.2.I20100512-1900) // SVN Team Provider (0.7.9.I20100512-1900)
If I understand your question correctly, this is the state of your project:
_________________ B DEV_PROJ
/
A /
---------------------------------- trunk
C \
\_____________ D DEV_VERS
And you want all changes from A -> B in your DEV_VERS branch.
If so, what I would do is the following (the following is the command line equivalent, but it should be easy to find the Eclipse SVN GUI equivalent):
Find the revision of A:
svn log --stop-on-copy URL_OF_DEV_PROJ
The earliest commit revision number is the revision number of point A
Find the revision of B:
Assuming you want to merge all changes in the DEV_PROJ branch, the value of B is simply HEAD
Checkout DEV_VERS:
svn co URL_OF_DEV_VERS
Inside the directory of the checked out code from step 3, merge the changes from A to B as follows:
svn merge -r<RevisionOfA>:HEAD URL_OF_DEV_PROJ .
In short, what you're doing is taking the difference between A and B and merging it to DEV_VERS

How to merge branch to trunk folder using svn in eclipse

How to merge all changes in branch to trunk folder using svn in eclipse?
If you are using Subversive, you can look at the Merge dialogs.
In particular, for merging back to trunk, you would use "reintegrate":