NOTE: #1064472 is the big change here. It separates the old field export into two new exports "field_base" and "field_instance". This helps distribution developers export base field definitions and allows users to change field instances without causing the distribution feature to be marked as overridden.
Working upgrade to D7, minimal refactoring from D6.
Tested and being further developed on a new D7/CiviCRM4.2 fresh install, but should work fine for upgrading an existing D6 installation.