Subversion merging local changes into a branch

In my local working copy of Subversion, I have a copy of the trunk and code branch. I made changes to the trunk and want to copy these changes to my (currently clean) local copy of the branch.

I know that I can check the code on trunk and then use svn mergeit to get changes in the branch, but is there a way to do this without first checking the changes?

Unfortunately, diff / patch will not work, as there are changes in the code surrounding my changes between the chest and the branch. I know I svn mergecan handle them, but as I said, it’s better not to check your changes first.

Edited to add an example:

There is a file in the trunk containing the following:

File in trunk:                       File in branch:
apple                                apple
orange                               banana
pear                                 pear

In trunk, I add dragon fruitbelow pearto the trunk line file on my working copy. If I verified that modifying and using a merge to copy it to branches, Subversion would correctly add dragon fruitbelow pearto the branch version of the file.

svn diff something similar to the following is created on my copy of the trunk file:

Index: fruit.txt
===================================================================
--- fruit.txt  (revision 56)
+++ fruit.txt  (working copy)
@@ -1,3 +1,4 @@
 apple
 orange
 pear
+dragon fruit

It is clear that using the patch will not work, as it notices the difference between immutable texts.

What I want, without having to check anything, is to have the dragon fruitspecified after pearin both files, but not change the difference orange/ bananain any file.

+3
source share
4 answers

svn switch .

, svn merge, , .

+4

switch, merge, diff , , , ( , ; , ).

- , , .

WinMerge, TortoiseMerge - , , .

+1

, svn diff, , , . , , , .

, , diff.

svn merge svn://path/to/trunk /path/to/working-copy

. - , .

,

svn commit /path/to/working-copy -m "Merged latest trunk changes into the branch"

svn diff /path/to/trunk > my-new-code.patch

, ,

cd /path/to/working-copy patch -p0 -i /path/to/my-new-code.patch

​​ , ... .

: , , :

, , 30 , , 56

  • svn up /path/to/branch-WC
  • svn up /path/to/trunk-WC -r 30
  • svn merge svn://path/to/trunk -r 55:56 /path/to/trunk-WC
  • cd /path/to/trunk-WC
  • svn diff /path/to/trunk-WC > /path/to/branch-WC/mychange.patch
  • cd /path/to/branch-WC
  • patch -p0 -i mychange.patch

, , - , . , , , .

, 55:56, " ". 55:56 /, diff .

If the change in revision 56 depends on previous sets of changes, you may need to resolve some conflicts or merge a few more changes (since this version 30 of the trunk will not know about them), but this should be exactly what you need.

+1
source

This question is old, but still I'm posting the right solution

http://ariejan.net/2007/07/03/how-to-create-and-apply-a-patch-with-subversion

In short, trunk do

svn diff > ~/trunk.diff

and then on the root branch

patch -p0 -i ~/trunk.diff
+1
source

Source: https://habr.com/ru/post/1725150/


All Articles