Search code examples
svnmergebranchtortoisesvn

Tortoise SVN update a branch anfter merging to trunk


Goodmorning,

Two devs, for example Bill and Max, are using tortoise SVN and they have created a trunk for a project (called "prj-trunk"); after that, they made two branch (with branch/tag option of tortise), one for each dev (called "prj-branch-max" and "prj-branch-bill"). In his branch Max made same modification and in the other Bill modify other file. Now is time to merge in the trunk, so one dev use "merge" option of tortoise for put his code in trunk, and after that, other dev "merge" his file to trunk. So the scenario now is that: Prj-Trunk with all modification, prj-merge-max only with max's modifications and prj-merge-bill with only bill's modification. So what is the best way to update the two merge with all modification? The first think I try is, starting with updated prj-trunk, make a merge with "merge" option pointing to "prj-branch-max" but tortoise SVN not find any modification (so the file updated from bill and merged in trunk, aren't recognized as new). I also try to make another branch with "branch/tag" option pointing to "prj-branch-max" but tortoise SVN return error (it say "already exist"). So what is correct way to do? Thanks you

Resuming:

Time prj-trunk branch-max branch-bill
t0 creation with file A.c, B.c, etc.. not exist not exist
t1 no modification branch from trunk branch from trunk
t2 no modification fila A.c modified file B.c modified
t3 merge from Max (A.c updated, B.c old) no modification no modification
t4 merge from Bill (both file are updated) no modification no modification
t5 [no modification] try to merge from trunk BUT not found any modification, so merge aborted by TortoiseSVN [as for Max]
t6 [no modification] try to branch (off curse, is not the right procedure, but it is the last try!) from trunk BUT already exist, so branch aborted by TortoiseSVN as for Max
t7 [no modification] delete folder in local and commit the delete in server; after that brench another time from trunk (that is up-to-date with all modification)... this is the wrong way, but i didn't discover any other solution as for Max

Ok please someone can tell me how to do the correct procedure starting from time #4 for update bill and max's brench??


Solution

  • When creating a branch in Subversion, it is created in the repository. The working copy is unaffected and needs to be switched to the newly created branch in order to change it.

    Using the command line client and the conventional trunk-branches layout, one would issue the following commands; in TortoiseSVN, one would use the analogous actions:

    touch A.c B.c
    svn add A.c B.c
    svn commit -m"Initial, empty files"
    svn copy ^/trunk ^/branches/max -m"Create branch for Max"
    svn copy ^/trunk ^/branches/bill -m"Create branch for Bill"
    
    # At this point, working copy is still on trunk
    svn switch ^/branches/max
    vi A.c # make changes, etc.
    svn commit -m"Max' changes to A"
    
    svn switch ^/branches/bill
    vi B.c # make changes, etc.
    svn commit -m"Bill's changes to B"
    
    # Now let's bring it together in trunk
    svn switch ^/trunk
    svn merge ^/branches/max .
    # Resolve conflicts, if any (there shouldn't be any)
    svn commit -m"Merge Max' changes"
    svn merge ^/branches/bill .
    # Resolve conflicts, if any (there shouldn't be any)
    svn commit -m"Merge Bill's changes"
    
    # Now let's merge those changes to Max' branch
    svn switch ^/branches/max
    svn merge ^/trunk .
    # Resolve conflicts, if any (there shouldn't be any)
    svn commit -m"Merge from trunk"
    
    # Same for Bill
    

    For more information on branching and merging, refer to the canonical resource on Subversion, the Red Bean Book.