Migrating from Bzr to Git (Single branch)

We migrated the ChaloBEST Repository from bzr to git. While migration is not a rocket science any more and there are a lot of blogs and threads about this. This post is a simple step as how to and also as self note.

Step 1. Branch out your bzr repo.

<code> $ bzr branch "url to your bzr repo"</code>

Step 2.cd into your new branch and do the following

<code> $ git init </code>
<code> $ git remote add origin "url to git report" </code>
<code> $ bzr fast-export `something`|git fast-import</code>

Step 3. In case your original git repo is not empty, please do a

<code> $ git pull </code>

Step 4.  Now do a

<code>$ git reset --hard  HEAD</code>

Step 5. Now commit the changes using

<code> $git commit -m "some message"</code>

Step 6.  Push the changes

<code> $git push </code>

Here are some links that helps out with migrating both branches and master.

To the south, sir!

It has been sometime while playing with Django. One problem that I face mostly is making changes in the model and expect the change to reflect itself on the fly. Django, however does not like this idea and does not let you do so. In most case if you are making a model and want to create the DB schema you will do something like this:

python manage.py syncdb

This will create your model, however once created and then if you want to make changes in the schema, you are not going anywhere. So this is where we need to go south.
Django south generally works in this way:

python manage.py schemamigration <appname> --initial

Then you do a

python manage.py migrate <appname>

This is enough to create a migration directory and track changes to your model based in the appname you are using.
So now if you are making changes to the column, you will be using south. The next few lines will deal with screwing thing inside south as well as making you model change successful. One piece of caution though, this will/may delete your existing data, so be careful.
Let say, you end up with an error like this while migrating using south.

! These migrations are in the database but not on disk:
some migrations here
! I’m not trusting myself; either fix this yourself by fiddling
! with the south_migrationhistory table, or pass –delete-ghost-migrations
! to South to have it delete ALL of these records (this may not be good).

This happens because there is conflict in the original model and the model you are trying to implement.

The following steps will help:

Undo changes in the model.py intended to have the change and delete the migration folder in the folder, then run

python manage.py migrate <appname> --delete-ghost-migration

This step will delete all the migrations that has not trickled down properly.
If your app is already managed by south then run the next step, else if your app was previously managed by syncdb only, use this command first:

python manage.py convert_to_south <appname>

Coming back to our steps:


python manage.py schemamigration <appname> --init


python manage.py migrate <appname> --fake

The argument –fake will record the changes but will not write it to the DB.
Now redo the changes in the model.py

python manage.py schemamigration <appname> --auto

The argument –auto will keep track of the changes happening over the initial change/previous changes.

python manage.py migrate <appname>

And that’s it, you are done and your changes has flown to the DB.
Please read south documentation for more details, it can be found here.

Random Scriblings

Theres quite lot to  say :

1. Gave one more talk on OSM at mukti 09

2. Visited Kolkata Book Fair and help folks at IOTA stall .It was awesome .Detailed blog coming up

3. Fedora talk at mukti 09 on 6th .Event page up (need suggestions)

4.Visited bijra today and had lot of feedback (complaints) from them .

5. Got a lit of petrol almost decades after recent price cut for RS 50.

6. Harman Baweja still cant act .

7. Sign of twitter becoming mainstream in India .Read here.