##// END OF EJS Templates
wireproto: support /api/* URL space for exposing APIs...
wireproto: support /api/* URL space for exposing APIs I will soon be introducing a new version of the HTTP wire protocol. One of the things I want to change with it is the URL routing. I want to rely on URL paths to define endpoints rather than the "cmd" query string argument. That should be pretty straightforward. I was thinking about what URL space to reserve for the new protocol. We /could/ put everything at a top-level path. e.g. /wireproto/* or /http-v2-wireproto/*. However, these constrain us a bit because they assume there will only be 1 API: version 2 of the HTTP wire protocol. I think there is room to grow multiple APIs. For example, there may someday be a proper JSON API to query or even manipulate the repository. And I don't think we should have to create a new top-level URL space for each API nor should we attempt to shoehorn each future API into the same shared URL space: that would just be too chaotic. This commits reserves the /api/* URL space for all our future API needs. Essentially, all requests to /api/* get routed to a new WSGI handler. By default, it 404's the entire URL space unless the "api server" feature is enabled. When enabled, requests to "/api" list available APIs. URLs of the form /api/<name>/* are reserved for a particular named API. Behavior within each API is left up to that API. So, we can grow new APIs easily without worrying about URL space conflicts. APIs can be registered by adding entries to a global dict. This allows extensions to provide their own APIs should they choose to do so. This is probably a premature feature. But IMO the code is easier to read if we're not dealing with API-specific behavior like config option querying inline. To prove it works, we implement a very basic API for version 2 of the HTTP wire protocol. It does nothing of value except facilitate testing of the /api/* URL space. We currently emit plain text responses for all /api/* endpoints. There's definitely room to look at Accept and other request headers to vary the response format. But we have to start somewhere. Differential Revision: https://phab.mercurial-scm.org/D2834

File last commit:

r32601:01280ec5 stable
r37064:1cfef569 default
Show More
bundlespec.txt
84 lines | 2.6 KiB | text/plain | TextLexer
Mercurial supports generating standalone "bundle" files that hold repository
data. These "bundles" are typically saved locally and used later or exchanged
between different repositories, possibly on different machines. Example
commands using bundles are :hg:`bundle` and :hg:`unbundle`.
Generation of bundle files is controlled by a "bundle specification"
("bundlespec") string. This string tells the bundle generation process how
to create the bundle.
A "bundlespec" string is composed of the following elements:
type
A string denoting the bundle format to use.
compression
Denotes the compression engine to use compressing the raw bundle data.
parameters
Arbitrary key-value parameters to further control bundle generation.
A "bundlespec" string has the following formats:
<type>
The literal bundle format string is used.
<compression>-<type>
The compression engine and format are delimited by a hyphen (``-``).
Optional parameters follow the ``<type>``. Parameters are URI escaped
``key=value`` pairs. Each pair is delimited by a semicolon (``;``). The
first parameter begins after a ``;`` immediately following the ``<type>``
value.
Available Types
===============
The following bundle <type> strings are available:
v1
Produces a legacy "changegroup" version 1 bundle.
This format is compatible with nearly all Mercurial clients because it is
the oldest. However, it has some limitations, which is why it is no longer
the default for new repositories.
``v1`` bundles can be used with modern repositories using the "generaldelta"
storage format. However, it may take longer to produce the bundle and the
resulting bundle may be significantly larger than a ``v2`` bundle.
``v1`` bundles can only use the ``gzip``, ``bzip2``, and ``none`` compression
formats.
v2
Produces a version 2 bundle.
Version 2 bundles are an extensible format that can store additional
repository data (such as bookmarks and phases information) and they can
store data more efficiently, resulting in smaller bundles.
Version 2 bundles can also use modern compression engines, such as
``zstd``, making them faster to compress and often smaller.
Available Compression Engines
=============================
The following bundle <compression> engines can be used:
.. bundlecompressionmarker
Examples
========
``v2``
Produce a ``v2`` bundle using default options, including compression.
``none-v1``
Produce a ``v1`` bundle with no compression.
``zstd-v2``
Produce a ``v2`` bundle with zstandard compression using default
settings.
``zstd-v1``
This errors because ``zstd`` is not supported for ``v1`` types.