robince
robince

Reputation: 10967

bzr: copy file from one branch to another unrelated branch

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

Upvotes: 1

Views: 410

Answers (1)

bialix
bialix

Reputation: 21473

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.

Upvotes: 2

Related Questions