[#7062] set first email to primary if none; unset primary when its deleted
[#7022] ticket:519 UnicodeDecodeError on side-by-side diff text
[#7022] Fixed pep8 error

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>
[#6982] [#6995] [#7019] ticket:520 Author on repo history page is missing sometimes