5

We are merging changes from the trunk to the branch. While we do this, the merge info gets recorded.

Since there might be other changes in the branch, is there a safe way to commit only the files affected due to the merge (assuming no other changes are there) along with the merge properties/info ?

" Lets say i want to merge revision 'r1' from trunk to branch. I do a merge from trunk to branch for 'r1'. Now for 'r1', in the branch folder, the merge information is recorded. If I do a svn diff in branch, it shows the '.' has modified, and shows that 'r1' is part of the merge properties. Now how do i commit the files modified due to 'r1' being merged only, along with the merge properties which says 'r1'. "

Abhilash L L
  • 366
  • 2
  • 7
  • 16
  • What do you mean with "other changes"? Changes in your working copy, which do not belong into that branch? – Tobias Mar 28 '13 at 08:41
  • @TobiasZander Yea. Changes on other files in the branch not relating to the merge. The problem is, we can commit the files individually, but have not been able to commit only the merge properties/info – Abhilash L L Mar 28 '13 at 09:16
  • I'm not sure, if I understand your problem correctly. If you just want to commit the merge-info, just deselect all other files when committing. If you only want to merge specific revision, you can also select only these revisions when doing a select. What svn client do you use? – Tobias Mar 28 '13 at 09:27
  • @TobiasZander Lets say i want to merge revision 'r1' from trunk to branch. I do a merge from trunk to branch for 'r1'. Now for 'r1', in the branch folder, the merge information is recorded. If I do a svn diff in branch, it shows the '.' has modified, and shows that 'r1' is part of the merge properties. Now how do i commit the files modified due to 'r1' being merged only, along with the merge properties which says 'r1'. Does this help / make sense ? :| – Abhilash L L Mar 28 '13 at 09:42
  • I suppose your issue is that, your branch working copy is having some local uncommitted changes and on the same working copy you want merge some revision (mentioned as r1 in your question) from the parent. But, while committing you need to commit only the merged files and not the local uncommited files which were present earlier before the merge operation. Am I understanding your question correctly? – RinoTom Apr 04 '13 at 12:16
  • @RinoTom yea, most of it. When i try to commit from the folder, i can selectively list the files. My doubt is how do i include the merge properties/info, which records that a particular revision (say r1) had been merged from trunk. I dont want to commit the whole folder, which will send all other changes – Abhilash L L Apr 04 '13 at 17:56

2 Answers2

2

If you are using SVN clients like TortoiseSVN, in a normal merge the mergeinfo will be updated as a folder property of the root folder automatically and it will list the folder with a property change during the commit listing of files.

If this is not coming automatically for your commit, then you can even do this even manually by following steps if you are using TortoiseSVN client (with the assumption root as parent, mytask as current task branch, subtask as an already merged back branch from current branch and programs as your code folder in each brach):

  1. Right click the programs folder on your workign copy of the branch mytask and select the option TortoiseSVN-->Properties.
  2. In the new window if you already have previous mergeinfo recorded then it will list the property svn:mergeinfo with the values similar to the values below:

    root/programs:1-489

    root/task/mytask/task/subtask/programs:380-410

    Then you can do the following steps:

    a) Select the option Edit-->Advanced in the window by selecting svn:mergeinfo item and update the mergeinfo you want to commit click 'OK'.

  3. In the new window, if you don't have any previous mergeinfo, then you can go for following steps:

    a) Select the option New-->Advanced.

    b) Select svn:mergeinfo from the dropdown list, add appropriate mergeinfo in the value textbox and save the same.

  4. Do SVN Commmit by clicking the programs folder and it will list programs folder in files to commit with only property change and you can commit it.

On the otherhand

If you want to commit only the merged files during your merge from the parent to the working copy and keep the locally modified other files uncommitted, then, there is no direct way to achieve this. The indirect way is to keep two seperate working copies (let us say copy1 and copy2) of your task branch (mytask) and perform the following steps:

  1. copy1 is having all the local changes and you can keep that aside for a while
  2. SVN checkout a new working copy copy2 of your branch.
  3. Merge the changes from your parent to copy2 and commit that. This ensures that you are commiting only the merged changes to the server with all the mergeinfo you want.
  4. Then go to your copy1, do an SVN update and it will get the new merged changes from server to this working copy. (If there are some files which are updated during merge and changed by you during local changes as well, then it will conflict during this SVN update). Resolve the conflicts and you can continue with your local changes then.
RinoTom
  • 2,278
  • 2
  • 26
  • 40
1

This is an old topic but, since I also needed something similar and didn't find anything on stackoverflow, here's my take: Use 'svn commit --depth=empty folder_with_mergeinfo merged_files'.

In my case I was merging two branches and if I try to 'svn ci branch' it will try to commit everything modified under that branch. Using --depth=empty ensures only the folder merge info and the files you want are committed.

fencekicker
  • 732
  • 1
  • 8
  • 18
  • This does not seem to commit the changed files. – trysis Jun 07 '17 at 13:54
  • It should, if you add them to the svn command line like my comment says. Of course, this is only practical if you haven't changed too many files. – fencekicker Jun 08 '17 at 14:44
  • Sorry, I thought the line was too long and there was no space between `folder_with_mergeinfo` and `merged_files`. – trysis Jun 08 '17 at 18:22