question: public void mergeElementsRelations ( final OsmElement mergeInto , final OsmElement mergeFrom ) { ArrayList < Relation > fromRelations = mergeFrom . getParentRelations ( ) != null ? new ArrayList < Relation > ( mergeFrom . getParentRelations ( ) ) : new ArrayList < Relation > ( ) ; ArrayList < Relation > toRelations = mergeInto . getParentRelations ( ) != null ? mergeInto . getParentRelations ( ) : new ArrayList < Relation > ( ) ; try { for ( Relation r : fromRelations ) { if ( ! toRelations . contains ( r ) ) { dirty = true ; undo . save ( r ) ; RelationMember rm = r . getMember ( mergeFrom ) ; RelationMember newRm = new RelationMember ( rm . getRole ( ) , mergeInto ) ; r . replaceMember ( rm , newRm ) ; r . updateState ( OsmElement . STATE_MODIFIED ) ; apiStorage . insertElementSafe ( r ) ; mergeInto . addParentRelation ( r ) ; mergeInto . updateState ( OsmElement . STATE_MODIFIED ) ; apiStorage . insertElementSafe ( mergeInto ) ; } } recordImagery ( ) ; } catch ( StorageException sex ) { } }
target:  Assumes mergeFrom will deleted by caller and doesn't update back refs