record: abort on malformed patches instead of crashing
record: ignore trailing content when parsing patches - introduce 'other' lines

This makes record work more like import which ignores for instance mail footers
in a patch file.

This also makes it possible for TortoiseHg to preview unapplied patches
containing such footers.
commit: allow closing "non-head" changesets

Backout acd61dc44a39. The changeset prevented closing non-head changesets but
did not provide any rationale or test case and I don't see what value it adds.
Users might have their reasons to commit something anywhere - and close it
immediately.

And contrary to the comment that is removed: The topo heads set is _not_
included in the branch heads set of the current branch. It do not include
closed topological heads.

The change thus prevented closing commits on top of closing commits. A valid
usecase for that is to merge closed heads to reduce the number of topological
heads.

The only existing test coverage for this is the failing double close in
test-revset.t. It was added in 3cc2e34d7a7d and seems to not be intentional.
export: export working directory parent by default

A common usecase for export is to preview the patch that will be patchbombed or
to see what changed in a revision found by bisect. Showing the working
directory parent is thus a useful and obvious default.
wireproto: clarify cryptic 'remote: unsynced changes' error message on push

The message was not very much to the point and did not in any way help an
ordinary user.

'repository changed while preparing/uploading bundle - please try again'
is more correct, gives the user some understanding of what is going on, and
tells how to 'recover' from the situation.

The 'bundle' aspect could be seen as an implementation detail that shouldn't be
mentioned, but I think it helps giving an exact error message.

The message could still leave the user wondering why Mercurial doesn't lock the
repo and how unsafe it thus is. Explaining that is however too much detail.
spelling: fix typos and spelling errors
check-code: catch trailing space in comments
check-code: check txt files for trailing whitespace
debugrebuildstate: clarify that rev can't be specified without -r

-r has a default value of '' in the command line. The function default value of
'tip' is thus never used and any attempt at specifying revisions without -r
will fail.

It seems like then intended behavior was that 'hg debugrebuildstate' without
any parameters should set the parents to tip. That would be very confusing now
when the command primarily is used to recover from incorrect stat info.

It is apparently undocumented that '' is the same as '.' ... unless it is
passed in a place where revsets are used.
debugstate: rename to debugdirstate

There is a lot of state, but this command is for debugging the dirstate.
debugrebuildstate: rename to debugrebuilddirstate

There is a lot of state, but this command is for rebuilding the dirstate.
subrepo: chain the original exception to SubrepoAbort

The tracebacks in subrepos are truncated at the point where the original
exception is caught and SubrepoAbort is raised in its place since 9e3910db4e78.
That hides the most relevant subrepo methods when an error occurs.  Python 2.x
doesn't support chaining exceptions, so it is manually done here for manual
printing later.
ui: add support for fully printing chained exception stacks in ui.traceback()

Currently, only SubrepoAbort has a cause chained to it.
ui: add 'force' parameter to traceback() to override the current print setting

This will allow a current traceback.print_exc() call in dispatch to be replaced
with ui.traceback() even if --traceback was not given on the command line.