views:

24

answers:

1

Is it possible to copy a file from one branch to another unrelated branch while preserving history for that file?

+1  A: 

Bazaar has no direct support for this operation.

Though you can achieve this goal with additional tools. But it's not very trivial operation. You can use bzr-fasimport plugin to export full history of your branch into fastimport stream, then filter history for required file and create new branch with only this one file and its history:

bzr fast-export > full-branch.fi
bzr fast-import-filter -i foo.txt full-branch.fi > only-foo.fi
bzr fast-import only-foo.fi foo-only-branch

Then merge foo-only-branch into your destination branch

bzr merge /path/to/foo-only-branch -r0..-1

NOTE: after fast-export/fast-import dance the history of only-foo will be incompatible with original branch, so you can't do this trick several times.

bialix
Thanks - that's really helpful! (hoped it would be a bit easier but I know its not what they're designed for)
thrope