-
Notifications
You must be signed in to change notification settings - Fork 116
Migrating branches from bzr
The Fluidity migration to Github required a set of history re-writes that purged very large files, which had been committed accidentally, from the history. For this reason all branches need to be rebased on the master
branch before being uploaded to Github. The following explains how to convert your bzr branch to git locally and then offers two methods to sync your branch with master
.
The following set of commands will clone the purged master
branch from github and convert the branch mybranch
into the same local git repository. The original method is described here.
git clone https://github.com/FluidityProject/fluidity.git
bzr branch lp:~myuserid/fluidity/mybranch
touch marks.git
cd fluidity
bzr fast-export --marks=../marks.bzr --git-branch=mybranch ../mybranch | git fast-import --import-marks=../marks.git --export-marks=../marks.git
The converted branch will have diverged from master
due to the file purges. There are two ways to fix this:
Create a new branch and git cherry-pick
all relevant commits across. This method should be preferred for small sets of commit, since it is much cleaner and avoids complex rebasing. For this you should do:
git checkout master
git checkout -b mynewbranch
git cherry-pick <relevant_commits>
Once you have migrated all relevant changes you can push you branch up to Github with:
git push origin mynewbranch
If you want to migrate a long-standing development branch, cherry-picking might be a bit impractical. In this case you can perform a git rebase master
with automatic conflict resolution to bring your branch in line with master
:
git checkout mybranch
git rebase master -p -s recursive -X theirs
This method will inevitably try to re-commit certain commits from the history that have been changed during the file purge. These will trigger known conflicts that should be resolved like this:
error: could not apply 06503bc... Some more Burgers equation work
Resolve by doing git rebase --skip
twice(!).
error: could not apply 3603d7f... Some more changes to bring all aqua-planet simulations in-line
Resolve by accepting remote changes and re-apply.
[detached HEAD f8a759e] Remove the reservoir prototype code written in the legacy format in preparation for the release candidate
Resolve by accepting remote changes and re-apply.
Following this rebase you will find two alien commits in your branch (concerned with documentation for a legacy_reservoir
test case). These need to be removed with git rebase --interactive
before pushing your branch to Github.
If all else fails, use diff to copy over the changes (but not the revision history) from bzr to a new git branch:
git checkout https://github.com/FluidityProject/fluidity.git git_repo
bzr checkout lp:~fluidity-core/fluidity/my_branch bzr_repo
cd git_repo
git checkout <the corresponding SHA-1 hash of the HEAD revision in the bzr repository>
cd ..
diff -rupN --exclude '.*' git_repo bzr_repo > changes.diff
cd git_repo
git checkout -b my_new_git_branch_name
git apply changes.diff
# Use 'git add' to add any untracked files
# And then use 'git commit -a' to commit the changes