scmutil: create directories in a race-safe way during update

With the new parallel update code, it is possible for multiple
workers to try to create a hierarchy of directories at the same
time. This is hard to trigger in general, but most likely during
initial checkout.

To deal with these races, we introduce a new ensuredirs function
whose contract is to ensure that a directory hierarchy exists - it
will ignore a failure that implies that the desired directory already
exists.
blackbox: adds a blackbox extension

Adds a blackbox extension that listens to ui.log() and writes the messages to
.hg/blackbox.log. Future commits will use ui.log() to log commands, unhandled
exceptions, incoming changes, and hooks.  The extension defaults to logging
everything, but can be configured via blackbox.track to only log certain events.
Log lines are of the format:  "date time user> message"

Example log line:
2013/02/09 08:35:19 durham> 1 incoming changes - new heads: d84ced58aaa

--HG--
extra : amend_source : b96df18ec32491ba047b8aba5f3b104be0e4e564
blackbox: log the commands that are run

Uses ui.log to log which commands are run, their exit code, the time taken,
and any unhandled exceptions thrown.

Example log lines:
2013/02/09 08:35:19 durham> add foo
2013/02/09 08:35:19 durham> add exited 0 after 0.02 seconds

Updates the progress tests because they use a mocked time.time() which these
changes affect.

--HG--
extra : amend_source : 00f0c58a856224248cda75b50638b18235b18c1f
blackbox: logs python and extension hooks via ui.log()

Logs python and extension hooks to ui.log() for viewing in the blackbox.

Example log lines:
2013/02/09 08:35:19 durham> pythonhook-preupdate: hgext.eol.preupdate finished in 0.01 seconds
2013/02/09 08:35:19 durham> exthook-update: echo hooked finished in 0.02 seconds

--HG--
extra : amend_source : d2296ae36ff3e0e954363e3830401b18d46d3c4f
blackbox: log incoming changes via ui.log()

Logs incoming changes to a repo to ui.log(). Includes the number of changes
and the hashes of the heads after the new changes.

Example log line:
2013/02/09 08:35:19 durham> 1 incoming changes - new heads: cb9a9f314b8b

Currently the blackbox logs the unix user that is performing the push/pull.
It would be nice to log the http authorized user as well so it works with
hgweb, but that's outside the scope of this commit.

--HG--
extra : amend_source : e52255ad109742eeffb25d07c7921f237b286a66
blackbox: adds a 'blackbox' command for viewing recent logs

Adds a 'hg blackbox' command for viewing the latest entries in the blackbox log.
By default it shows the last 10 entries, but -l allows the user to specify.
blackbox: tests for the blackbox extension

A few tests to cover the blackbox extension. Covers commands, hooks, and
incoming changes.
blackbox: fix a failing pyflakes test
blackbox: fix copyright
blackbox: only show new heads on incoming

The blackbox was logging every head after every incoming group.
Now we only log the heads that have changed.

Added a test.  Moved the hooks test to the bottom of the file since
the hooks interfer with the tests after it.
util: make ensuredirs safer against races
tests: quickly check if the glob line already matches the output

This happens when a path with "/" as only glob char is matched on a non windows
platform. (Currently one third of all glob matches.)
The slowdown on windows and the speedup on other os are neglectable.
tests: inform on Windows about unnecessary glob lines

When glob lines directly match on windows, "/" (and not "\") was output in the
path on the line. No glob matching is necessary in this case.

The test output will look like this (when 5 tests have passed and no 4 has an
unnecessary glob):
...
Info, unnecessary glob: info about some/thing (glob)
..

--HG--
extra : rebase_source : fc340183c1f7b5633a6415bdd3806eccfcc00eea
tests: append glob to filename output when required (windows)

This lines were introduced in cd403d6d96ef and made the test fail on
windows.

--HG--
branch : stable
tests: remove glob from output lines containing no glob character
check-code: warn about line glob match with no glob character (?*/)

--HG--
extra : rebase_source : b0ce5cc19f16364337ddee8e2d5be64e322d645b
merge with stable
backout: use cmdutil.revert directly instead of commands.revert

Before this change, backout would explicitly set the options it passed
to commands.revert in order to fall thru most of its logic and call
cmdutil.revert. This change makes it clearer what backup is trying to
accomplish and makes it robust against changes to the revert command.

--HG--
extra : rebase_source : a6300d15b1e82121a9b646126ba35809068f340e
backout: remove unnecessary frobbing of addremove option

There's no way for addremove to show up in backout's opts dictionary. It
was being set manually because cmdutil.commit expected it to be there
(and would throw an exception if it wasn't). This was fixed waaaaaaay
back in:

changeset:   5829:784073457a0f
user:        Kirill Smelkov <kirr@mns.spb.ru>
date:        Thu Jan 10 12:07:18 2008 +0300
summary:     cmdutil.commit: extract 'addremove' from opts carefully

--HG--
extra : rebase_source : 67fff6f7f7bbe643f8cb21567d05d1533589c94d
backout: remove unnecessary dict copy

This is step 1 to remove backout's call to commands.commit. We don't use
the options again anywhere below except for backout's own purposes,
specifically choosing a merge tool, so we just write the commit options
in directly.

--HG--
extra : rebase_source : 0bd924ff1d80ad01410368fe25e278b6150a6ebf