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?
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.
精彩评论