Skip to content

Instantly share code, notes, and snippets.

@larryprice
Created April 10, 2017 16:59
Show Gist options
  • Save larryprice/85590b3565387b30ed12111b143e3adf to your computer and use it in GitHub Desktop.
Save larryprice/85590b3565387b30ed12111b143e3adf to your computer and use it in GitHub Desktop.
Migrating libertine repos from bzr to git
--- commands.py 2016-04-18 22:24:36.000000000 +0300
+++ /usr/lib/python2.7/dist-packages/fastimport/commands.py 2017-04-10 17:17:41.473457256 +0300
@@ -501,11 +501,11 @@
else:
sep = b' '
- name = utf8_bytes_string(name)
+ #name = utf8_bytes_string(name)
email = fields[1]
- email = utf8_bytes_string(email)
+ #email = utf8_bytes_string(email)
return b''.join((name, sep, b'<', email, b'> ', ("%d" % fields[2]).encode('ascii'), b' ', offset_str))
  1. Needed to patch fastimport (see fastimport.patch)
  2. Switch to bzr directory
  3. git init
  4. bzr fast-export --plain . | git fast-import
  5. rm -rf .bzr
  6. git log --format=%H --first-parent > hashes
  7. tac hashes | tail -n +2 > reversed_hashes
  8. Determine initial commit (we'll refer to it as $initial_commit)
  9. git checkout $initial_commit
  10. `git checkout -b top-level-commits
  11. cat reversed_hashes | xargs -I % bash -c "git cherry-pick % || git cherry-pick -m 1 %"
  12. Create a new repo on git repo on any service (refer to address as $repo_addr)
  13. git remote add origin $repo_addr
  14. git push origin top-level-commits:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment