From what I have read, when merging SVN before 1.4 I have to do this "by hand" because the previous-merge info is not available:
svn merge svn://server/repo/trunk#revision svn://server/repoo/branch .
Since this is the first time I am merging what do I put in revision? Do I use the one at "branch time"?
Also, is there any way of doing this within the Eclipse-Collabnet client or do I have to do it via Tortoise?
The command to use is explained in the SVN book. Assuming you started your maintenance branch at revision 341, and the trunk is at revision 405, and the working copy is pointing to the trunk, the command should be:
svn merge -r 341:405 http://svn.example.com/repos/calc/branches/my-maintenance-branch
Remember that a merge consists in applying a diff from point A to point B into the working copy. Here, points A and points C are in the same branch: the maintenance branch: all the changes you made in this branch must be reapplied on the trunk.
Related
We've just spent two weeks working down the wrong path on a problem (with all the commits to our SVN repository that go with that). We've now come up with the right solution (which needs our code base to go back to what it was two weeks ago). We should have branched two weeks ago, but that is irrelevant now.
Clearly, I can make a second checkout of the project and then copy that over the current version of the repository and check that in.
Is there a cleaner way to do this without a second checkout?
There are many ways to do what you want. The simplest would be to check out a new copy of the codebase to a dev machine, specifying the revision for the commit made just before you went down the wrong development path. Then, simply check that code back in as the latest revision. Not only do you effectively "revert" the codebase to that revision, if you find out that some element of your wrong solution was useful after all, you still have easy access to those elements.
Also, as was said, you can branch the codebase at any time, at any revision. Simply cut a branch of the revision before you began your work, and continue along your new dev path. Keep in mind that merging this branch back into the trunk could be problematic; you'd want the end result of development in the branch to replace the codebase of the trunk wholesale. That's possible but it can get messy.
There are a few ways of handling this:
Revert your changes:
$ svn merge -r$rev2:$rev1 .
This is assuming that $rev2 > $rev1. This will back out the changes between these two revisions. If you're backing out a single revision, you can use this:
$ svn merge -c -$rev .
That is, the revision should be a negative number. This will back out just that one revision.
Recreate the Branch
If this work was not done on trunk, but on a branch, and you pretty much want to toss out that branch, you can simply recreate the branch, and even delete the old bad one. Branches (and tags) can be created from any point in time:
$ svn cp -r$rev $REPO/branches/$bad_branch/$proj $REPO/branches/$new_branch
$ svn delete $REPO/branches/$bad_branch
The solution provided by Mike works for me.
In a separate branch
$ svn merge -r 303:302 http://svn.example.com/repos/calc/trunk
(this undoes the change between 302 and 303).
Then you can commit the changes in your branch, test and then merge back to the trunk as normal.
How can I resolve this merging issue ?
My project has 1 branch which I used for production and head. 2 times it worked merging production branch into head. Each time I created a tagged head after merging to have a start point for the next merge. Its important to note that I do not create a new branch after each merge, I reuse the branch.
The problem is, if I try to merge my branch to head. eclipse cvs acts like it is comparing and listing all files as "to update", even if file head version is greater than the file branch version.
ex: head file version is 1.8 and branch file version is 1.6. This file was already merged in last merge. When trying to merge I specifiy as "common base version" the head tag that I created after the last merge. Still, eclipse cvs suggests to override head modifications and use the branch version. This behaviour applies to all files.
I dont know what to do. I dont want to manually merge hundreds of files.
thanks for any help
Look at the example:
|tag_h1 |tag_h2
-----------------------------------------> trunk
\ ^ ^
\ / /
\----------------------------------> my_branch
|tag_b1 |tag_b2
On branch there are tags tag_b1 and tag_b2 before each merge, and in trunk, tags tag_h1 and tag_h2.
For a next merge from branch to trunk, the "common base version" of Eclipse will be the one tagged with tag_b2. With CVS update, if you specify two parameters, you will get modifications between these two merged in your working directory. Giving Branch or version to be merged (end tag)=my_branch and Common base version (start tag)=tag_b2 will merge changes from tag_b2 until my_branch end, like calling CVS from command line:
$ cvs up -j tag_b2 -j my_branch
I always tag from where I will merge, and before and after the merge, like this:
|tag_before |tag_after
--------------------------------->
^
/
------------------------------>
|tag_from
Giving the tags a name I can recognize.
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
I am trying to contribute to a project that uses Subversion. I used Mercurial and its hgsubversion extension to clone the repo. My work takes place on a feature branch.
How do I keep the feature branch up to date with stuff that happens on the default branch (hg speak) aka the trunk (svn speak)?
So I used hg up feature to update to the feature branch, then hg pull which gave me changesets on the default branch. So I did hg merge default, the committed the merge, then tried hg push to send my changesets to Subversion. And Mercurial said: "Sorry, can't find svn parent of a merge revision."
I have finally figured out how to get my repository un-wedged after an event like that described in the question, so that I can continue work without having to re-clone the parent repository (which is, obviously, a quite slow operation when you are pulling from Subversion!). If the "tip" of Subversion outruns you so that you cannot push any more, just make sure that you have the built-in "rebase" extension activated in your Mercurial through a $HOME/.hgrc line like this:
[extensions]
rebase =
And then you should be able to run this command when your repository gets wedged:
$ hg rebase --svn
If I understand this correctly, it dissolves your current branch that has taken you away from Subversion HEAD, and rebuilds it atop the branch "tip" in Mercurial that corresponds to the HEAD in Subversion. From there, you can keep working and successfully do pushes again. It has always worked for me so far; let me know if you run into any problems!
Mercurial as a few different branching modes: http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/
The one you're describing is 'named branches', which is the most popular when you're working with a repo that's accessed only via mercurial (or hg-git).
However, when you're using hg-subversion so that you're pushing changes to/from subversion, which only nominally has branches, you're better off keeping all of your mercurial changes in the 'default' named branch, and using the 'clones and branches' pattern (which I prefer anyway).
Specifically, that message Sorry, can't find svn parent of a merge revision. isn't a descendant of a revision that has a direct match in subversion.
Were I you, I'd reclone from svn, and then move my work into that repo's 'default' branch with the 'transplant' command (packaged extension). If you want multiple features in parallel w/ hg-subversion use separate clones (they're so cheap), as it's more in line with how subversion thinks about branches.
I needed to figure this out for myself and wrote it up here:
http://notebook.3gfp.com/2010/05/pushing-a-new-feature-from-a-mercurial-repo-into-an-svn-repo/
I haven't yet figured out how to close a branch in subversion and have the mercurial graph look correct.
A common scenario when using source control is to have a development branch along with versioned release branches. We use CVS, with HEAD as the development branch, and a branch named e.g. release-6-2 for the current release of a product.
Development of new features go into the development branch only, but bug fixes sometimes have to be checked into both the development branch and the current release branch. This can get quite tedious at times, so I am looking for practical ways to accomplish this.
When a file to be commited is in synch on the two branches, I am in particular looking for a quick "commit to these branches" solution.
(We use CVS as our source control system, so any CVS-specific answers are nice. However, it is also interesting to see whether other source control systems can offer a better way.
On the client side we use Eclipse, so Eclipse solutions are good. But if you have a non-Eclipse solution, that is fine too.)
Apply your fix to the oldest release branch required. Then merge the change to the next release branch and so on until you merge from the last release branch to the HEAD.
Say the oldest version of your product is 1.0 and you also have 1.1 and 1.5 releases. New features for the next release are being added to the HEAD. If a bug is found in 1.0, you apply the fix to the 1.0 branch. Merge from 1.0 to the 1.1 branch. Merge from 1.1 to the 1.5 branch, and finally merge from the 1.5 branch to the HEAD.
Merging from branch to branch is better than applying the fix manually to each branch.
With CVS you have to mannually keep track of what versions are merged, so that you do not include the same revisions when you do your next merge.
If you change to use Subversion, merging from branch to branch is easier. Eclipse's subversion tool will keep track of what revisions you have previously merged, greatly simplifying the task of doing repeated merges between two branches.
Changing to Subversion from CVS is easy(ish). You won't be the first to have made such a move.
Like awalshe said, it's better to merge between branches. To cherry-pick a merge, the method described in Pragmatic Version Control using CVS is very good:
In the branch - tag (PRE_FOO) before the change, make the changes and commit, tag after the change (POST_FOO). Then, in trunk, merge using the tags:
cvs up -j PRE_FOO -j POST_FOO
Merging between branches is much easier and safer in SVN, and it's trivial to convert your entire CVS history to SVN - see cvs2svn. You should use either SVN 1.5, or - with earlier SVN versions - svnmerge.