util: rename 're' to 'remod'

Upcoming patches will introduce a binding called 're'.
util: move compilere to a class

We do this to allow us to use descriptors for other related methods.

For now, util.compilere does the same thing. Upcoming patches will remove it.
match: use util.re.compile instead of util.compilere
config: use util.re.compile instead of util.compilere
commands: use util.re.compile instead of util.compilere
util: remove no longer used compilere
util.re: move check for re2 into a separate method

We're going to use the same check for another method in an upcoming patch.
util.re: add an escape method

The escape method in at least one of the modules called 're2' is in C. This
means it is significantly faster than the Python code written in 're'.

An upcoming patch will have benchmarks.
match: use util.re.escape instead of re.escape

For a pathological .hgignore with over 2500 glob lines and over 200000 calls to
re.escape, and with re2 available, this speeds up parsing the .hgignore from
0.75 seconds to 0.20 seconds. This causes e.g. 'hg status' with hgwatchman
enabled to go from 1.02 seconds to 0.47 seconds.
run-tests: write out scripts in binary mode

Caught because Python 3 refuses to write bytes to a non-binary fd.

--HG--
extra : rebase_source : 08615dd4da8d28f2484c7c404462e671edaa35e5
largefiles: avoid unnecessary creation of .hg/largefiles when opening lfdirstate

Previously, the directory '.hg/largefiles' would always be created if it didn't
exist when the lfdirstate was opened.  If there were no standin files, no
dirstate file would be created in the directory.  The end result was that
enabling the largefiles extension globally, but not explicitly adding a
largefile would result in the repository eventually sprouting this directory.

Creation of this directory effectively changes readonly operations like summary
and status into operations that require write access.  Without write access,
commands that would succeed without the extension loaded would abort with a
surprising error when the extension is loaded, but not actively used:

  $ hg sum -R /tmp/thg --config extensions.largefiles=
  parent: 16541:00dc703d5aed
   repowidget: specify incoming bundle by plain file path to avoid url parsing
  branch: default
  abort: Permission denied: '/tmp/thg/.hg/largefiles'


This change is simpler than changing the callers of openlfdirstate() to use the
'create' parameter that was introduced in ae57920ac188, and probably how that
should have been implemented in the first place.