[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Merge, reintegrate, and merge with tree conflicts

From: Stefan Sperling <stsp_at_elego.de>
Date: Mon, 25 Feb 2013 18:29:04 +0100

On Mon, Feb 25, 2013 at 11:11:19AM -0500, James Hanley wrote:
> This is /really/ confusing as with the script I'm using reintegrate
> the first time to go from branch to trunk, but you're saying I also
> have to use it from trunk to branch - that is from origin to copied
> branch. I've read through Julian's post (repeatedly) and if I
> understand right, the "reintegrate" option will "flip" the perspective
> of the current merge and "sync" merges from then on... This seems
> /really/ accident prone

Yes, it is very prone to accident, which is why it's not documented,
as Julian himself pointed out in his post.

The feature will officially be available in 1.8. Until then, you can
use this trick or just ignore the fact that it exists if it confuses
your users too much. It will be much easier once Subversion can figure
out the correct merge direction on its own.

I just mentioned it because of the claim that doing this was impossible
with SVN, which isn't true. It's inconvenient at the moment, but not
impossible. The inconvenience will be addressed in the next release.

> as I'm still unclear as to with Julian's post
> what are the implications if there multiple branches off the
> originator involved, and multiple branch generations (branch of
> branch) involved - so refactoring what Julian wrote:
>
> Copy T->B1.
> Merge T->B1 -- use a "sync" merge
> Merge T->B1 -- use a "sync" merge
> Merge B1->T -- use a "reintegrate" merge
> Merge B1->T -- use a "sync" merge
> Merge B1->T -- use a "sync" merge
> Merge T->B1 -- use a "reintegrate" merge
> Merge T->B1 -- use a "sync" merge
> Copy T->B2
> Merge T->B1 -- use a "sync" merge
> Merge T->B2 -- use a "sync" merge
> Merge B2->T -- use a "reintegrate" merge
> Merge T->B1 -- use a ???? merge

I believe a sync merge would do here.

The last direction in a merge from T to B1 was T->B1. That's what
counts. B2 has nothing to do with it.

> Copy B2->B2.1
> Merge B2->B2.1 -- use a "sync" merge?
> Merge B2.1->B2 -- use a "reintegrate" merge?
> Merge B2->T -- use a ??? merge

Again, "sync" should be alright. The last merge involving B2 and T
was in the B2->T direction.

> More merge shenanigans
>
> What about cherry picking such that a bug is fixed in the trunk and
> needs to be back-ported to a point release?

I've already mentioned this briefly here:
http://svn.haxx.se/users/archive-2013-02/0238.shtml

Generally I would recommend to cherry-pick only to or from branches
which never merge in their entirety with another branch.

Say you have a release branch for all your 1.0.x releases. This branch
will live as long as 1.0.x releases are shipping (1.0.0, 1.0.1, etc.),
and then it will simply become uninteresting. You'd never attempt to merge
this branch into a branch representing a different release (i.e. merge two
code bases meant for different releases with one another in their entirety),
and hence such a branch is suitable to be cherry-picked from and to.

In particular, you want to avoid situations where cherry-picked changes
end up being merged in a circular fashion, such as:

  initial commit on B1 -> cherry-pick from B1 to B2 -> merge B2 into T
  -> merge T into B1 # initial change is applied again to B1

In this kind of situation, assuming both B1 and B2 are over time kept in
sync with T, it is more appropriate to commit the change to T initially.

It's a good idea to design your branching/merging strategy in a way
that avoids cycles. There are many ways of doing so, so I cannot
elaborate further without more information about your current strategy.

> If it's only available with automatic handling in 1.8, when will that
> be released (as http://subversion.apache.org/roadmap.html says Q4 2012
> - /unconfirmed/) and we are over halfway through Q1 2013...

When it's done. The community is already discussing the 1.8 release and
is very eager to get it done. We're currently still applying some stability
fixes for the new local-move-tracking feature. Follow the dev@ list if
you're curious.
 
If you'd like to help testing 1.8 once alpha and beta releases come out,
that would be highly appreciated! Just watch this list or the announce@
list which receives much less traffic than the users@ list does.
I believe there will be binary packages available for easy installation.

> For completeness sake, can you test if the reintegrate option is
> removed completely from the script, how does it perform against 1.8 -
> as I don't have a sandbox to test?

Sure. Here's a transcript of a run of your script when run with 1.8
and all --reintegrate options removed.

$ bash -x enduceTreeConflict.sh
+ svn --version
svn, version 1.8.0-dev (under development)
   compiled Feb 25 2013, 10:54:05 on x86_64-unknown-openbsd5.3

Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - handles 'http' scheme
  - handles 'https' scheme

+ svnadmin --version
svnadmin, version 1.8.0-dev (under development)
   compiled Feb 25 2013, 10:54:05 on x86_64-unknown-openbsd5.3

Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository back-end (FS) modules are available:

* fs_fs : Module for working with a plain file (FSFS) repository.
* fs_base : Module for working with a Berkeley DB repository.

+ echo '###########################################'
###########################################
+ echo '### Attempting most simple reproduction ###'
### Attempting most simple reproduction ###
+ echo '###########################################'
###########################################
+ mkdir simple
+ pushd simple
/tmp/simple /tmp
+ svnadmin create repo
++ pwd
+ svn checkout file:///tmp/simple/repo wc
Checked out revision 0.
+ echo 'Create basic repo structure'
Create basic repo structure
+ cd wc
+ mkdir branches tags trunk
+ svn add branches tags trunk
A branches
A tags
A trunk
+ svn commit -m 'basic repo structure'
Adding branches
Adding tags
Adding trunk

Committed revision 1.
+ echo 'Navigate to trunk'
Navigate to trunk
+ cd trunk
+ echo 'Create initial project layout'
Create initial project layout
+ mkdir -p Program
+ svn add Program
A Program
+ svn commit -m 'Initial project layout'
Adding Program

Committed revision 2.
+ echo 'Create branch'
Create branch
+ cd ..
+ cd branches
+ svn cp '^/trunk/Program' Program_rc1
Checked out revision 2.
A Program_rc1
+ svn commit -m 'initialize integration branch'
Adding Program_rc1

Committed revision 3.
+ echo 'add new feature'
add new feature
+ cd Program_rc1
+ mkdir -p treeconflict
+ svn add treeconflict
A treeconflict
+ svn commit -m 'add new feature'
Adding treeconflict

Committed revision 4.
+ echo 'Reintegrating feature to trunk'
Reintegrating feature to trunk
+ cd ../../trunk/Program
+ svn up
Updating '.':
At revision 4.
+ svn merge '^/branches/Program_rc1' .
--- Merging r3 through r4 into '.':
A treeconflict
--- Recording mergeinfo for merge of r3 through r4 into '.':
 U .
+ svn commit -m 'Reintegrating feature to trunk'
Sending .
Adding treeconflict

Committed revision 5.
+ echo 'Rebaselining feature from trunk'
Rebaselining feature from trunk
+ cd ../../branches/Program_rc1
+ svn up
Updating '.':
At revision 5.
+ svn merge '^/trunk/Program' .
--- Recording mergeinfo for merge between repository URLs into '.':
 U .
+ echo 'We have a tree conflict!!!'
We have a tree conflict!!!
+ popd
/tmp
+ echo '################################################'
################################################
+ echo '### Attempting to show real world use issue. ###'
### Attempting to show real world use issue. ###
+ echo '################################################'
################################################
+ mkdir someWhatRealWorldApplication
+ pushd someWhatRealWorldApplication
/tmp/someWhatRealWorldApplication /tmp
+ svnadmin create repo
++ pwd
+ svn checkout file:///tmp/someWhatRealWorldApplication/repo wc
Checked out revision 0.
+ echo 'Create basic repo structure'
Create basic repo structure
+ cd wc
+ mkdir branches tags trunk
+ svn add branches tags trunk
A branches
A tags
A trunk
+ svn commit -m 'basic repo structure'
Adding branches
Adding tags
Adding trunk

Committed revision 1.
+ echo 'Navigate to trunk'
Navigate to trunk
+ cd trunk
+ echo 'Create initial project layout'
Create initial project layout
+ mkdir -p Program/foo Program/bar Program/bla
+ svn add Program
A Program
A Program/foo
A Program/bar
A Program/bla
+ svn commit -m 'Initial project layout'
Adding Program
Adding Program/bar
Adding Program/bla
Adding Program/foo

Committed revision 2.
+ echo 'Create integration/team branch structure'
Create integration/team branch structure
+ cd ..
+ cd branches
+ mkdir -p int usr/andy usr/bob usr/charlie usr/david
+ svn add int usr
A int
A usr
A usr/andy
A usr/bob
A usr/charlie
A usr/david
+ svn commit -m 'create integration/team branch structure'
Adding int
Adding usr
Adding usr/andy
Adding usr/bob
Adding usr/charlie
Adding usr/david

Committed revision 3.
+ echo 'initialize integration branch'
initialize integration branch
+ cd int
+ svn cp '^/trunk/Program' Program_rc1
A Program_rc1/foo
A Program_rc1/bar
A Program_rc1/bla
Checked out revision 3.
A Program_rc1
+ svn commit -m 'initialize integration branch'
Adding Program_rc1

Committed revision 4.
+ echo 'create usr branch main line & branch'
create usr branch main line & branch
+ cd ../usr/andy
+ svn cp '^/branches/int/Program_rc1' Program_rc1_main_line
A Program_rc1_main_line/bla
A Program_rc1_main_line/foo
A Program_rc1_main_line/bar
Checked out revision 4.
A Program_rc1_main_line
+ svn cp Program_rc1_main_line Program_rc1_new_feature
A Program_rc1_new_feature
+ svn commit -m 'create usr branch main line & branch'
Adding Program_rc1_main_line
Adding Program_rc1_new_feature

Committed revision 5.
+ echo 'add new feature'
add new feature
+ cd Program_rc1_new_feature
+ mkdir -p treeconflict/burr treeconflict/snburr treeconflict/snurr
+ svn add treeconflict
A treeconflict
A treeconflict/burr
A treeconflict/snburr
A treeconflict/snurr
+ svn commit -m 'add new feature'
Adding treeconflict
Adding treeconflict/burr
Adding treeconflict/snburr
Adding treeconflict/snurr

Committed revision 6.
+ echo 'Perform downstream merging'
Perform downstream merging
+ cd ../Program_rc1_main_line
+ svn up
Updating '.':
At revision 6.
+ svn merge '^/branches/int/Program_rc1' .
--- Recording mergeinfo for merge of r5 through r6 into '.':
 U .
+ svn commit -m 'Rebaselining usr/andy main line from integration main line'
Sending .

Committed revision 7.
+ cd ../Program_rc1_new_feature
+ svn up
Updating '.':
At revision 7.
+ svn merge '^/branches/usr/andy/Program_rc1_main_line' .
--- Merging r5 through r7 into '.':
 U .
--- Recording mergeinfo for merge of r5 through r7 into '.':
 G .
+ svn commit -m 'Rebaselining usr/andy feature from andy'\''s main line'
Sending .

Committed revision 8.
+ cd ../Program_rc1_main_line
+ svn up
Updating '.':
At revision 8.
+ svn merge '^/branches/usr/andy/Program_rc1_new_feature' .
--- Merging differences between repository URLs into '.':
A treeconflict
A treeconflict/snurr
A treeconflict/burr
A treeconflict/snburr
 U .
--- Recording mergeinfo for merge between repository URLs into '.':
 U .
+ svn commit -m 'Reintegrating usr/andy feature to andy'\''s main line'
Sending .
Adding treeconflict

Committed revision 9.
+ cd ../../../int/Program_rc1
+ svn up
Updating '.':
At revision 9.
+ svn merge '^/branches/usr/andy/Program_rc1_main_line' .
--- Merging differences between repository URLs into '.':
A treeconflict
A treeconflict/snurr
A treeconflict/burr
A treeconflict/snburr
 U .
--- Recording mergeinfo for merge between repository URLs into '.':
 G .
+ svn commit -m 'Reintegrating usr/andy main line to integration main line'
Sending .
Adding treeconflict

Committed revision 10.
+ echo 'Perform additional downstream merging'
Perform additional downstream merging
+ cd ../../usr/andy/Program_rc1_main_line
+ svn up
Updating '.':
At revision 10.
+ svn merge '^/branches/int/Program_rc1' .
--- Merging differences between repository URLs into '.':
 U .
--- Recording mergeinfo for merge between repository URLs into '.':
 G .
+ echo 'We have a tree conflict!!!'
We have a tree conflict!!!
+ svn status
 M .
$
Received on 2013-02-25 18:29:57 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.