hgweb: side-by-side comparison functionality

Adds new web command to the core, ``comparison``, which enables colorful
side-by-side change display, which for some might be much easier to work with
than the standard line diff output. The idea how to implement comes from the
SonicHq extension.
The web interface gets a new link to call the comparison functionality. It lets
users configure the amount of context lines around change blocks, or to show
full files - check help (also in this changeset) for details and defaults. The
setting in hgrc can be overridden by adding ``context=<value>`` to the request
query string. The comparison creates addressable lines, so as to enable sharing
links to specific lines, just as standard diff does.
Incorporates updates to all web related styles.

Known limitations:
* the column diff is done against the first parent, just as the standard diff
* this change allows examining diffs for single files only (as I am not sure if
  examining the whole changeset in this way would be helpful)
* syntax highlighting of the output changes is not performed (enabling the
  highlight extension has no influence on it)

--HG--
rename : mercurial/templates/gitweb/filediff.tmpl => mercurial/templates/gitweb/filecomparison.tmpl
rename : mercurial/templates/monoblue/filediff.tmpl => mercurial/templates/monoblue/filecomparison.tmpl
rename : mercurial/templates/paper/filediff.tmpl => mercurial/templates/paper/filecomparison.tmpl
util, posix: eliminate encodinglower and encodingupper

2ebe3d0ce91d claims this was needed "to avoid cyclic dependency", but there is
no cyclic dependency.

windows.py already imports encoding, posix.py can import it too, so we can
simply use encoding.upper in windows.py and in posix.py.

(this is a partial backout of 2ebe3d0ce91d)
localpeer: return only visible heads and branchmap

Now that we have localpeer, we can apply filtering on heads and branchmap the
same way it's done for wireprotocol peer.
repo: move visibleheads and visiblebranchmap logic in discovery

They were previously inside the mercurial.phases module, but obsolete
logic will need them to exclude `extinct` changesets from pull and
push.

The proper and planned way to implement such filtering is still to apply a
changelog level filtering. But we are far to late in the cycle to implement and
push such a critical piece of code (changelog filtering). With Matt Mackall
approval I'm extending this quick and dirty mechanism for obsolete purpose.

Changelog level filtering should come during the next release cycle.
obsolete: do not exchange extinct changesets

Extinct changesets are excluded from all exchange operations. This is a silent
exclusion because the user should not need to be aware of them.

There is no reason to strongly enforce this exclusion except implementation
simplicity. User should be able to explicitly request an extinct changeset in
the future.
hidden: move hiddenrevs set on the repository

This set is always accessed through the repo for now. Having this set
carried by the changelog make it complicated to:

- initialize it, computing hidden set may involve revset call
- lazy compute it, (1) only the changelog can detect someone access it,
                   (2) only the repo have enought knowledge to compute it.

In later version I expect he changelog to apply filtering itself and the set to
be carried by changelog again.
obsolete: mark unreachable extinct changesets as hidden

The repo.hiddenrevs set is updated with all extinct() changesets which aren't
descendants of either:

- the current working copy,
- a bookmark,
- a tag.
checkheads: extract branchmap preprocessing

The checkheads function is far too complicated. This extract help to explicite
what part of the preprocessing are reused by the actual check.

This the first step toward a wider refactoring.
_updatebranchcache: prevent deleting dict key during iteration

We use dict.keys() to fetch all keys before starting to delete some. Otherwise
python complains that the dictionnary is altered during iteration.
checkheads: simplify the structure build by preprocessing

All useful data are now gathered in a single dictionnary.
`branchmapsummary` is renamed to `headssummary` and its return value
is greatly simplified.
checkheads: extract bookmark computation from the branch loop

No branch specific data are used in the computation of the bookmarked heads. We
can only compute it once.
obsolete: add an any successors function

This function yield every nodes which succeed to a group of nodes.

The first user will be checkheads who need to know if we push successors for
remote extra heads.
checkheads: take future obsoleted heads into account

If we push some successors they will likely create a new head on
remote. However as the obsoleted head will disappear after the push we
are not really increasing the number of heads.

There is several case which will lead to extra being actually pushed. But this
first changeset aims to be simple. See the inline comment for details.

Without this change, you need to push --force every time you want to
push a newer version which is very error prone.

The remote side still display +n heads on unbundle because it does not have the
obsolete marker at unbundle time.
checkheads: extract branchmap preprocessing

The checkheads function is far too complicated. This extract help to explicite
what part of the preprocessing are reused by the actual check.

This the first step toward a wider refactoring.