rebase: keep original mq patch format (Issue1574)
Rebase now doesn't make assumptions about which format has been
used for a mq patch (git or normal).
Before finalizing a patch it keeps track of the original format,
by reading its header, and then restores the format when reimporting
it.
This way it also allows for having mixed styles.
Note: this version corrects a failure in the test
rebase: store/restore arguments correctly
Keep and keepbranches were lost after an interruption
issue1578: fix crash: do not use synthetic changesets as merge parents.
move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.