Merge branch with excludes

Asked by Denis Golovan

Hi

I'd like to ask - if there any possibility to merge branches with a list of files excluded?
I mean - is there any way to perform an automatic partial merge (something like cherry-picking).

I am trying to keep all system configs and user scripts in Bazaar, but I have several work machines.
So for now merging changes between them is rather painful. I use ordinary diff/patch functionality without any support from VCS.

Less preferred solution would be to use bzr send functionality, but for now does not support files exclusion as well.

Maybe it is possible to implement this using plugin?
I'd appreciate any help on this.
Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Martin Pool (mbp) said :
#1

2009/9/24 Denis Golovan <email address hidden>:
> New question #83635 on Bazaar:
> https://answers.launchpad.net/bzr/+question/83635
>
> Hi
>
> I'd like to ask - if there any possibility to merge branches with a list of files excluded?
> I mean - is there any way to perform an automatic partial merge (something like cherry-picking).
>
> I am trying to keep all system configs and user scripts in Bazaar, but I have several work machines.
> So for now merging changes between them is rather painful. I use ordinary diff/patch functionality without any support from VCS.
>
> Less preferred solution would be to use bzr send functionality, but for now does not support files exclusion as well.
>
> Maybe it is possible to implement this using plugin?
> I'd appreciate any help on this.
> Thanks.

Hi Denis,

Probably the best solution for now is to do the merge, then say 'bzr
revert X' on the files or directories that you don't want to have
merged. That will put them back like they were in the merge
destination.

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Denis Golovan (denisgolovan) said :
#2

Hi Martin

Thanks for answer.

I tried your solution with bzr revert, but unfortunately it has nasty side-effects.

Right now if file1 is added to branch1 and is meant to be excluded from merging and not added to branch2, merging branch1 to branch2 produces .moved directories which are not reverted using bzr revert command. So i.e. /etc directory is left damaged after revert.

I think some bzr merge engine logic by means of patch/plugin is needed.
Maybe some hints how to implement such behavior?

Revision history for this message
Martin Pool (mbp) said :
#3

2009/9/25 Denis Golovan <email address hidden>:
> Question #83635 on Bazaar changed:
> https://answers.launchpad.net/bzr/+question/83635
>
>    Status: Answered => Open
>
> Denis Golovan is still having a problem:
> Hi Martin
>
> Thanks for answer.
>
> I tried your solution with bzr revert, but unfortunately it has nasty
> side-effects.
>
> Right now if file1 is added to branch1 and is meant to be excluded from
> merging and not added to branch2, merging branch1 to branch2 produces
> .moved directories which are not reverted using bzr revert command. So
> i.e. /etc directory is left damaged after revert.

I don't understand precisely what you mean, you might want to file a
bug with a reproduction recipe.

>
> I think some bzr merge engine logic by means of patch/plugin is needed.
> Maybe some hints how to implement such behavior?

Sure, we're happy to help you do that, but let's define just what is
wanted here, and how it should be different from revert. If revert is
buggy but would otherwise do the job, let's just fix revert.

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Denis Golovan (denisgolovan) said :
#4

Ok. Here is a bash script with a recipe of my problem.
I am not sure it's a bzr revert bug. It's just how it works with unversioned files.

#!/bin/bash

mkdir branch1
bzr init branch1

echo "branch1/1" > branch1/1.txt
(cd branch1 ; bzr add 1.txt; bzr commit -m "b1 commit1" )

bzr branch branch1 branch2
# add non-versioned file to branch2 tree
echo "branch2/2" > branch2/2.txt

# add versioned file to branch1 tree
echo "branch1/2" > branch1/2.txt
(cd branch1 ; bzr add 2.txt; bzr commit -m "b1 commit2" )

#now, let's try to merge branch1 to branch2
(cd branch2; bzr merge ../branch1 )
#here we have original branch2/2.txt moved to 2.txt.moved

#now imagine yourself that branch2/2.txt was the file a want to be exclude from merging
#I try to revert merge
(cd branch2; bzr revert 2.txt)
#Ok. branch2/2.txt is now deleted, but previous file (unversioned) is left with the name 2.txt.moved
#Now imagine yourself if this branch2/2.txt was part of /etc configuration files...

Revision history for this message
Launchpad Janitor (janitor) said :
#5

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Denis Golovan (denisgolovan) said :
#6

Well. My question expired.

Maybe someone can add something?
I presented my problem as I was asked

Revision history for this message
besy (besy) said :
#7

I've just tried it myself. It is like you said: The .moved ending will stay. If the merge causes a real conflict (with .THIS, .OTHER etc. files being created), you can use "bzr resolve". However, if there is a .moved file like in your example, I don't know what you could do about it. Maybe, one would need a "bzr undo file.txt" command which would undo the merge for a specified file or a modification of "bzr revert".

Revision history for this message
besy (besy) said :
#8

I have an idea: Have you tried the command "bzr view" in Bazaar 2.0.x? It might help you with your problem but I'm not sure. I haven't used this command yet.

Revision history for this message
Denis Golovan (denisgolovan) said :
#9

Hm.
This "filter views" is an interesting conception.
I'll try to play with them.
Thanks for hint.

Revision history for this message
besy (besy) said :
#10

Has "bzr view" solved your problems?

Can you help with this problem?

Provide an answer of your own, or ask Denis Golovan for more information if necessary.

To post a message you must log in.