templater: handle SyntaxError when parsing ui.logtemplate

Before, Mercurial would crash with a traceback ending with

  SyntaxError: unmatched quotes

if you configured

  [ui]
  logtemplate = {rev}\n

The SyntaxError is now catched and the string is re-parsed without
requiring quotes.

--HG--
branch : stable
parsers: strictly check for 20-byte hashes where they're required

--HG--
branch : stable
extra : rebase_source : e4534c359dfc379734c610195d12ec8497c24a3a
tag: run commit hook when lock is released (issue3344)

--HG--
branch : stable
extra : rebase_source : 35950502155710986c5d13d535002adfc11f617e
mq: qimport need wlock for --push - do that after releasing lock

qimport locking was introduced for phases in 29ea059be33c.

--HG--
branch : stable
extra : rebase_source : 08cb166af786ce0d31682c41abe4c4f396276d81
test-progress: fix whitespace typo

--HG--
extra : rebase_source : e6822f0207dd8b5efc2e61595f5569bcef3f2de6
progress: fix indentation

--HG--
extra : rebase_source : 7d7ac5527c2eb032cdb25062c52b3c333cdd7314
cleanup: eradicate long lines
cleanup: "x != None" -> "x is not None"
cleanup: replace hasattr() usage with getattr() in hghave
cleanup: "not x in y" -> "x not in y"
cleanup: "raise SomeException()" -> "raise SomeException"
cleanup: replace naked excepts with more specific ones
cleanup: replace naked excepts with except Exception: ...
unbundle: move bookmark update outside the lock

d16c99f16f00 introduced updatecurrentbookmark after unbundle, but that path
might end up taking a wlock after lock when writing the bookmarks.
largefiles: refactor downloading of all largefiles to generic function
largefiles: add --all-largefiles flag to pull
diffhelpers: use Py_ssize_t in _fix_newline()

Eliminates

  mercurial/diffhelpers.c(23) : warning C4244: 'initializing' : conversion from
  'Py_ssize_t' to 'int', possible loss of data
  mercurial/diffhelpers.c(26) : warning C4244: 'initializing' : conversion from
  'Py_ssize_t' to 'int', possible loss of data
  mercurial/diffhelpers.c(27) : warning C4244: 'initializing' : conversion from
  'Py_ssize_t' to 'int', possible loss of data
  mercurial/diffhelpers.c(30) : warning C4244: 'initializing' : conversion from
  'Py_ssize_t' to 'int', possible loss of data

when compiling for Windows x64 target using the Microsoft compiler.
diffhelpers: use Py_ssize_t in addlines()

Eliminates

  mercurial/diffhelpers.c(81) : warning C4244: '=' : conversion from
  'Py_ssize_t' to 'int', possible loss of data
  mercurial/diffhelpers.c(82) : warning C4244: '=' : conversion from
  'Py_ssize_t' to 'int', possible loss of data

when compiling for Windows x64 target using the Microsoft compiler.
diffhelpers: use Py_ssize_t in testhunk()

Eliminates

  mercurial/diffhelpers.c(143) : warning C4244: '=' : conversion from
  'Py_ssize_t' to 'int', possible loss of data
  mercurial/diffhelpers.c(144) : warning C4244: '=' : conversion from
  'Py_ssize_t' to 'int', possible loss of data

when compiling for Windows x64 target using the Microsoft compiler.
rebase: allow collapsing branches in place (issue3111)

We allow rebase plus collapse, but not collapse only? I imagine people would
rebase first then collapse once they are sure the rebase is correct and it is
the right time to finish it.

I was reluctant to submit this patch for reasons detailed below, but it
improves rebase --collapse usefulness so much it is worth the ugliness.

The fix is ugly because we should be fixing the collapse code path rather than
the merge. Collapsing by merging changesets repeatedly is inefficient compared
to what commit --amend does: commitctx(), update, strip. The problem with the
latter is, to generate the synthetic changeset, copy records are gathered with
copies.pathcopies(). copies.pathcopies() is still implemented with merging in
mind and discards information like file replaced by the copy of another,
criss-cross copies and so forth. I believe this information should not be lost,
even if we decide not to interpret it fully later, at merge time.

The second issue with improving rebase --collapse is the option should not be
there to begin with. Rebasing and collapsing are orthogonal and a dedicated
command would probably enable a better, simpler ui. We should avoid advertizing
rebase --collapse, but with this fix it becomes the best shipped solution to
collapse changesets.

And for the record, available techniques are:
- revert + commit + strip: lose copies
- mq/qfold: repeated patching() (mostly correct, fragile)
- rebase: repeated merges (mostly correct, fragile)
- collapse: revert + tag rewriting wizardry, lose copies
- histedit: repeated patching() (mostly correct, fragile)
- amend: copies.pathcopies() + commitctx() + update + strip