Encode special characters in branch names for `compare` command

Because the branch name becomes a URL component, special characters like
`#` need to be URI-encoded. Some characters are exempt from encoding:

* `/` can occur literally in a branch name
* Characters like `!.*'()` are allowed in URLs
* Characters like `^:~` are NOT encoded because git doesn't allow them
  in branch names, but they can be used in Compare view for stuff like:
  - `mislav:master`
  - `feature^`
  - `feature~3`
* If you specify a range for Compare, nothing is escaped and the caller
  is responsible for encoding branch names properly. This is because
  such expressions can include stuff like `@{1 week ago}` that
  branch-encoding would totally mess up.
Merge pull request #741 from github/funky-branch-compare

Encode special characters in branch names for `compare` command