hgweb: teach archive how to download a specific directory or file

The archive web command now takes into account the "file" request entry, if one
is provided.

The provided "file" is processed as a "path" corresponding to a directory or
file that will be downloaded.

With this change hgweb can to process requests such as:

    http://mercurial.selenic.com/hg/archive/tip.zip/mercurial/templates

This will download all files on the mercurial/templates directory as a zip file.
It is not possible to specify file patterns ('glob', 'relglob', 'path',
'relpath', 're', 'relre' nor 'set'). The server will reject those with a
403 HTTP error response.

Note that this is a first step to add support for downloading directories from
the web interface. A following patch will modify the archiveentry map entry on
the different templates so that it adds the current folder path to the archive
links.

--HG--
extra : rebase_source : 5db556840810cd9f05850a31db316ecd06685a0c
hgweb: change manifest archive links to only archive the current directory

When the web server shows the manifest for a single, non top directory, append
the path to the directory to the archive links. This makes the web server
generate archive files that only include the current directory (and its
subdirectories).

Note that archive links in other pages (e.g. changeset) or at the top of the
manifest are unchanged. Directory archive links have an extra "/" at the end
which does not impact the result of the archive operation. Keeping it there
made the implementation of this feature simpler.

--HG--
extra : rebase_source : 3ba1dab87e85a01980ad41afd211b3a145b9828a
util: add flag support to compilere
grep: use re2 if possible

Since re2 is enormously faster than Python's re module, this should
help performance, ceteris paribus. grep currently has other huge
performance problems that mask any gain :-(
Merge
rebase: fix --collapse when a file was added then removed

When a series of commits first adds a file and then removes it,
hg rebase --collapse prompts whether to keep the file or delete it. This is
due to it reusing the branch merge code. In a noninteractive terminal it
defaults to keeping the file, which results in a collapsed commit that is
has a file that should be deleted. This bug resulted in developers accidentally
commiting unintentional changes to our repo twice today, so it's fairly
important to get fixed.

This change allows rebase --collapse to tell the merge code to accept the
latest version every time without prompting.

Adds a test as well.
bookmarks: allow moving a bookmark forward to a descendant

Allow 'hg bookmark MARK', with an existing bookmark MARK, to move the
bookmark forward to the current or specified revision, if the target
revision is a descendant of the revision the bookmark currently points
to. Prints a status message including the revision the bookmark was
formerly at:

  $ hg bookmark Z
  moving bookmark 'Z' forward from 663762316562

Test coverage is added.

--HG--
extra : amend_source : 7beb52544988aea160f2036a9452c136d036dca7
bookmarks: fix test broken by 0bba1ff2ac7b

The added test reflects an error in printing the origin node of the
bookmark that I fixed before committing, but I forgot to update the
test (whoops).
bookmarks: allow (re-)activating a bookmark on the current changeset

Allow a bookmark that points to the current changeset to be made the
active bookmark without requiring --force. Previously, this would've
aborted with:

  abort: bookmark 'Z' already exists (use -f to force)

--HG--
extra : amend_source : 16fc6c1a87d90297871fcc0b9451ea5e00290582
bookmarks: moving the active bookmark deactivates it

After this change, moving the active bookmark somewhere other than the
current changeset (i.e., with --rev) deactivates it. Previously it would
remain in .hg/bookmarks.current, which seems like a bug.
revset: don't abort when regex to tag() matches nothing (issue3850)

This makes the tag("re:...") revset consistent with branch("re:...").

--HG--
extra : rebase_source : 81fa8a904c725eaf3ac6b8b8155b2441807a87c8
applyupdates: assign variable before we try to use it (issue3855)

The variable 'fd' was getting used with a value left over from a prior
iteration, causing a KeyError: '.hgsubstate'.
merge
largefiles: don't query the dirstate for key None

lfutil.splitstandin(f) can be None, and we query the dirstate for that without
checking if it is. This will cause problems with the upcoming move to critbit-
based dicts, since they only support strings as keys.

--HG--
extra : rebase_source : 03d5b97a7065492266fe4185234a684b50a21fd1
merge with crew-stable
blackbox: prevent failed I/O from causing hg to abort

Instead, we simply print a warning message if opening the blackbox log
file fails, or if writing to it fails.
blackbox: use util.getuser for portability

On Windows, our implementation is more robust than Python's version.
run-tests: only sort files when not given as argument

os.listdir returns the files in any order. This has to be sorted.
But when given as argument, the user should be allowed to set any order.

This restores the behaviour before 9848a94e2a.

--HG--
extra : rebase_source : 860008ce04d585482d5099c42d8203b32d8e3ead
bash_completion: nuke a duplicated function

--HG--
extra : amend_source : 633b1b2b35095b6fc1e7fcf89436ecff06b1683b
completion: add a debuglabelcomplete command

When completing a "label" (a symbolic name for a commit), the
bash_completion script currently has to invoke hg three times. For
a large repository, the cost of starting up and loading all the
necessary context over and over is very high.

For instance, in mozilla-central:

  time (export HGPLAIN=1; hg tags -q; hg bookmarks -q; hg branches) >/dev/null
  0.446 sec

Compare with the debuglabelcomplete command that this commit adds:

  time hg debuglabelcomplete >/dev/null
  0.148 sec

This greatly helps responsiveness.