Patch in hbase-4388 addresses some of above.
+ It increments HRI VERSION (and makes HRI able to deserialize the old format that has HTD)
+ We no longer have a migrated flag but a version in root for meta table (a short)
+ Migration should be idempotent now; we look at each row and check its HRI VERSION and if not current, do update
+ Duplicated code has been removed
+ We no longer do createTableDescriptor on each HRI scanned; just on the first.
+ Migration code has been coalesced some but still code spread about
+ There is no sanity checking that all HTDs for a table are equal. Not sure what we'd do if they were not equal other than warn. We wouldn't know which of them all to take. Patch in hbase-4388 takes the first regions HTD. This is usually the first updated; later updates could fail so its the first is likely the 'latest' iteration on HTD I'd guess.