Commit Graph

240 Commits

Author SHA1 Message Date
Mads Kiilerich
b778f12731 cleanup: fix some list comprehension redefinitions of existing vars
In all the remaining cases the comprehension variable is used for the same
thing as a previous loop variable.

This will mute some pyflakes "list comprehension redefines" warnings.
2014-08-15 04:37:46 +02:00
Pierre-Yves David
3d5f179a17 getbundle: add a `cg` boolean argument to control changegroup inclusion
The ``getbundle`` function was initially design to return a changegroup bundle.
However, bundle2 allows transmitting a wide range of data. Some bundle2
requests may not include a changegroup at all.

Before this changeset, the client would request a changegroup for
``heads=[nullid]`` and receive an empty changegroup.

We introduce an official boolean parameter, ``cg``, that can be set
to false to disable changegroup generation on getbundle. A new bundle2
capability is introduced to let the client know.
2014-05-31 16:48:29 -07:00
Pierre-Yves David
18d1ed009e wireproto: add a `boolean` type for getbundle parameters
This will be used to control inclusion of some parts in a bundle2.
2014-05-22 17:20:52 -07:00
Pierre-Yves David
047a4db399 wireproto: rephrase the error message for unknown getbundle parameters
In case of an unknown parameter passed to ``getbundle``, the server prints a
message and ignores the parameter. This message was misleadingly prefixed with
"abort: ". The use of "abort: " here is clearly wrong as nothing is actually
aborted and the ``getbundle`` call proceeds without the parameter.

The message is now prefixed with "warning: " and rephrased to make it clearer
that the parameter was simply ignored.
2014-05-27 14:45:31 -07:00
Pierre-Yves David
deb72642b3 getbundle: support of listkeys argument when bundle2 is used
A new ``listkeys`` is supported by getbundle. It is a list of namespaces whose
content should be included in the bundle.

An appropriate entry has been added to the wireproto map of getbundle arguments
and a new bundle2 capability is advertised.

There are still no codes that request such parts in core mercurial.
2014-05-27 15:43:09 -07:00
Pierre-Yves David
9ddf331cd4 wireproto: use pushkey.decodekey 2014-05-27 15:02:51 -07:00
Pierre-Yves David
3b4a115178 wireproto: use pushkey.encodekey 2014-05-27 15:00:08 -07:00
Pierre-Yves David
95482f20ff getbundle: declare type of parameters
In addition to listing the expected options for ``getbundle``, we also list their
types and handle the encoding/decoding automatically. This should make it easier
for extensions to transmit additional information to getbundle.
2014-05-22 09:53:52 -07:00
Matt Mackall
ba031d2d3b merge with stable 2014-05-29 15:41:16 -07:00
Pierre-Yves David
5877b7bbef wireproto: expose the list of getbundle arguments to extensions
For now, getbundle accepts a fixed number of arguments: ``heads``, ``common``
and ``bundlecaps``. We make this list exposed at the module level to let
extensions add content there. This is important for extensions that wish to use
bundle2 for other contents than changegroup.
2014-05-22 01:49:12 -07:00
Pierre-Yves David
ee9ac67c31 bundle2: support None parttype in BundleValueError
This will be used for errors at the stream level.
2014-05-28 16:46:58 -07:00
Pierre-Yves David
1b80836a48 bundle2: support transmission of params error over the wire
We picked a null character to split each parameter during the transfer. This is
fragile if the same character is used in parameter name. However other
codes will already behave in a strange way in that case, so we are not
introducing any regression. A better format may be picked for the final
version of the protocol.
2014-05-28 15:57:23 -07:00
Pierre-Yves David
72ac6a7248 bundle2: introduce a parttype attribute to BundleValueError
We will use the Exception for more that just unknown part type.
2014-05-28 15:51:19 -07:00
Pierre-Yves David
b5c6c1b880 bundle2: rename b2x:error:unknownpart to b2x:error:unsupportedcontent
This is a backward compatibility breakage per se. But bundle2 was explicitly
flagged as experimental, and this is one an error path anyway. So the worse
possible outcome from this change is to still have a crash but with a different
message.
2014-05-27 10:32:07 -07:00
Pierre-Yves David
d9f1652a77 bundle2: move exception classes into the error module
Exceptions should have known their place.
2014-05-28 15:31:05 -07:00
Pierre-Yves David
08bcb101f2 bundle2: rename UnknownPartError to BundleValueError
We are going to raise exceptions for a wider range of cases: unsupported
mandatory stream and part parameters.  We rename the exception with a wider
name.
2014-05-28 14:22:24 -07:00
Pierre-Yves David
121338752e bundle2: update all `addpart callers to newpart`
The new method is what we want in all current cases.
2014-05-23 15:59:19 -07:00
Pierre-Yves David
b4b66836e8 bundle2: gracefully handle PushRaced error during unbundle
Same drill again. We catch the PushRaced error, check if it cames from
a bundle2 processing, if so we turn it into a bundle2 with a part
transporting error information to be reraised client side.
2014-04-21 17:51:58 -07:00
Pierre-Yves David
716843e5d3 bundle2: fix raising errors during heads checking
If the heads on the server differ from the ones reported seen by the client at
bundle time, we raise a PushRaced exception. However, the part raising the
exception was broken.

To fix it, we move the PushRaced class in the error module so it can be
accessible everywhere without an import cycle.

A test is also added to prevent regression.
2014-04-21 18:59:09 -07:00
Pierre-Yves David
f5bff0c11f bundle2: gracefully handle UnknownPartError during unbundle
Same as for Abort error, we catch the error, encode it into a bundle2 reply
(expected by the client) and stream this reply. The client processing of the
error will raise the exception again.
2014-04-21 16:02:03 -07:00
Pierre-Yves David
3085949133 bundle2: gracefully handle abort during unbundle
Clients expect a bundle2 reply to their bundle2 submission. So we
catch the Abort error and turn it into a bundle2 containing a part
transporting the exception data. The unbundling of this reply will
raise the error again.
2014-04-21 15:48:52 -07:00
Pierre-Yves David
9761757d1d getbundle: pass arbitrary arguments all along the call chain
The wireprotocol command accepts arbitrary arguments, we are now passing such
arguments down the call chain.
2014-04-17 17:25:50 -04:00
Pierre-Yves David
9ab32b965e bundle2: require both client and server to opt in
Even if the server is bundle2-enabled, the client now has to opt-in in the
config too.
2014-04-17 16:04:58 -04:00
Pierre-Yves David
953b10a36c bundle2: move bundle2 config option to section "experimental"
We highlight the fact that this is experimental by moving it to an "experimental"
section, and we match the config name with the server capability name
`bundle2-exp`.
2014-04-17 16:01:58 -04:00
Pierre-Yves David
005c745f17 bundle2: rename server capability to bundle2-exp
For the same reason, we advertise this bundle2 implementation and format as
experimental. This will leave room for field testing in 3.0 but won't conflict
with a stable implementation in 3.1.
2014-04-17 15:33:17 -04:00
Pierre-Yves David
7e653a9c0f bundle2: use HG2X in the header
The current implementation of bundle2 is still very experimental and the 3.0
freeze is yesterday. The current bundle2 format has never been field-tested, so
we rename the header to HG2X. This leaves the HG20 header available for real
usage as a stable format in Mercurial 3.1.

We won't guarantee that future mercurial versions will keep supporting this
`HG2X` format.
2014-04-17 15:27:54 -04:00
Pierre-Yves David
9992968890 bundle2: advertise bundle2 caps in server capabilities
We can now retrieve them from the server during push. The capabilities are
encoded the same way as in `replycaps` part (with an extra layer of urlquoting
to escape separators).
2014-04-17 01:49:20 -04:00
Pierre-Yves David
fb104a18a2 bundle2: support for push over the wire
We use the new method defined in the past changeset to send a bundle2 stream and
receive one in reply. The http version is missing remote output support. This
will be done later using a bundle part.
2014-04-15 11:53:10 -04:00
Pierre-Yves David
15b0369836 wireproto: add a _calltwowaystream method on wirepeer
This method will be used by bundle2 pushes. It calls a command, feeds it with a
stream and receives another stream in reply.

Actual implementation for ssh and http will be done in later changesets.
2014-04-15 17:19:46 -04:00
Pierre-Yves David
523be79be9 bundle2: allow bundle2 for pulling over the wire
This changeset makes `wireprotocol` peers advertise bundle2 capability and
comply with bundle2 `getbundle` requests.

Note that advertising bundle2 could make a client try to use it for push. Such
pushes would fail. However, I do not expect any human being to have enabled
bundle2 on their server yet.
2014-04-15 15:20:33 -04:00
Pierre-Yves David
c9703fe999 bundle2: add a ui argument to readbundle
The bundle2 unbundler needs a ui argument. We are now passing this information
to `readbundle`.
2014-04-14 15:45:30 -04:00
Pierre-Yves David
009e9f6c33 bundle2: move readbundle into the exchange module
The `readbundle` function is going to understand the bundle2 header. We move the
function to a more suitable place before making any other changes.
2014-04-14 15:33:50 -04:00
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
Pierre-Yves David
69ae281a65 localrepo: add unbundle support
Localrepo now supports the unbundle method of pushing changegroups. We
plan to use the unbundle call for bundle2 so it is important that all
peers supports it. The `peer.unbundle` and `peer.addchangegroup` code
path have small difference so cause some test output changes. None of those
changes seems problematic.
2014-04-04 17:50:44 -07:00
Pierre-Yves David
9c50815f66 unbundle: extract the core logic in another function
The `exchange` module now contains an `unbundle` function that holds the core
unbundle logic. The wire protocol keeps its own unbundle function. It enforces
wireprotocol-specific logic and then calls the extracted function.

This aims at implementing unbundle for localrepo.
2014-04-04 17:28:59 -07:00
Pierre-Yves David
f6ff0fbdf6 unbundle: extract checkheads in its own function
We are going to refactor the unbundle function to have it working on
a local repository too. Having this function extracted will ease the process.

In the case of non-matching heads, the function now directly raises an
exception. The top level of the function is catching it.
2014-04-04 17:15:25 -07:00
Pierre-Yves David
6b9778c026 localrepo: move the addchangegroup method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.
2014-04-01 15:27:53 -07:00
Pierre-Yves David
8e0876686d localrepo: move the changegroup method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.

The peer API stay unchanged.
2014-04-01 15:08:27 -07:00
Pierre-Yves David
30f24fdb7a localrepo: move the getbundle method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.

The peer API remains unchanged.
2014-04-01 14:40:35 -07:00
Pierre-Yves David
f14b79a23f localrepo: move the changegroupsubset method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.

The peer API remains unchanged.
2014-04-01 14:25:03 -07:00
Pierre-Yves David
c6617aef8a wireproto: use decorator for the ubundle command 2014-03-28 14:43:30 -07:00
Pierre-Yves David
04af30a7a2 wireproto: use decorator for the stream command 2014-03-28 14:43:11 -07:00
Pierre-Yves David
5dd8ba7d3d wireproto: use decorator for the pushkey command 2014-03-28 14:42:55 -07:00
Pierre-Yves David
99c03cd1e0 wireproto: use decorator for the lookup command 2014-03-28 14:42:38 -07:00
Pierre-Yves David
fe6ed0903b wireproto: use decorator for the listkeys command 2014-03-28 14:42:21 -07:00
Pierre-Yves David
32d30d0970 wireproto: use decorator for the known command 2014-03-28 14:42:06 -07:00
Pierre-Yves David
8a8b960d73 wireproto: use decorator for the hello command 2014-03-28 14:40:44 -07:00
Pierre-Yves David
997e84e937 wireproto: use decorator for the heads command 2014-03-28 14:40:31 -07:00
Pierre-Yves David
73981cbf16 wireproto: use decorator for the getbundle command 2014-03-28 14:40:07 -07:00
Pierre-Yves David
a82db7631c wireproto: use decorator for the debugwireargs command 2014-03-28 14:39:06 -07:00
Pierre-Yves David
d39b82219d wireproto: use decorator for the changegroupsubset command 2014-03-28 14:38:40 -07:00
Pierre-Yves David
3b0626a933 wireproto: use decorator for the changegroup command 2014-03-28 14:38:19 -07:00
Pierre-Yves David
69ae194532 wireproto: use decorator for the capabilities command 2014-03-28 14:37:28 -07:00
Pierre-Yves David
d4a7f403ed wireproto: use decorator for the branches command 2014-03-28 14:37:02 -07:00
Pierre-Yves David
a0ec15e813 wireproto: use decorator for the branchmap command 2014-03-28 14:36:41 -07:00
Pierre-Yves David
16cb37a2d5 wireproto: use decorator for the between command 2014-03-28 14:36:05 -07:00
Pierre-Yves David
0797e04e6b wireproto: use decorator for the batch command 2014-03-28 14:35:36 -07:00
Pierre-Yves David
705b90da7b wireproto: add decorator for wire protocol command
Move move in the same direction we took for command line commands. each wire
protocol function will be decorated with its name and arguments.

Beside beside easier to read, this open the road to easily adding more metadata
(like security level or return type)
2014-03-28 14:30:11 -07:00
Pierre-Yves David
e3dee4d3e4 wireproto: drop the _decompress method in favor a new call type
We already have multiple call function for multiple return type. The
`_decompress` function is only used for http and seems like a layer violation.
We drop it in favor of a new call type dedicated to "stream that may be useful to
compress".
2014-03-28 14:24:13 -07:00
Pierre-Yves David
7d748aed99 wireproto: document protocol specific function of wirepeer
Those function are explicitly declared and documented now.
2014-03-28 12:29:34 -07:00
Pierre-Yves David
5d414d928b wireproto: introduce an abstractserverproto class
sshserver and webproto now inherit from an abstractserverproto class. This class
is introduced for documentation purpose.
2014-03-28 11:10:33 -07:00
Pierre-Yves David
271bd25192 wireproto: document possible return type
The wireprotocole command use a small set of class as return value. We document
the meaning of each of them.

AS my knowledge of wire protocol is fairly shallow, the documentation can
probably use improvement. But this is a better than nothing.
2014-03-28 11:37:42 -07:00
Pierre-Yves David
cae4a1d18a wireproto: move wireproto capabilities computation in a subfunction
It will help people that need to add capabilities (in a more subtle was that
just adding some to the list) in multiple way:

1. This function returns a list, not a string. Making it easier to look at,
   extend or alter the content.

2. The original capabilities function will be store in the dictionary of wire
   protocol command. So extension that wrap this function also need to update
   the dictionary entry.

   Both wrapping and update of the dictionary entry are needed because the
   `hello` wire protocol use the function itself. This is specifically sneaky for
   extension writer as ssh use the `hello` command while http use the
   `capabilities` command.

   With this new `_capabilities` function there is one and only one obvious
   place to wrap when needed.
2014-03-12 14:46:41 -07:00
Pierre-Yves David
342e942953 wireproto: extract capabilities list in outside the wireproto function
Before that it was over complicated to add capabilities from an extension.

This mimic was is done for capabilities in localrepo.
2014-03-11 01:38:02 -07:00
Augie Fackler
d394c651c2 wireproto: remove todict() and use {} literals instead 2014-03-12 13:00:51 -04:00
Benoit Boissinot
a898b587b8 bundle-ng: add bundlecaps argument to getbundle() command 2013-02-09 23:42:03 +01:00
Durham Goode
799e15746f clone: move file stream walk to a separate function
Moves the file walk out of the stream method so that extensions can override it.

This allows an extension to decide what files should be streamed, and in
particular allows a stream without filelogs.
2013-05-01 10:38:41 -07:00
Mads Kiilerich
bdab228647 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.
2013-04-11 14:54:18 +02:00
Kevin Bullock
93f9cb7f25 filtering: rename filters to their antonyms
Now that changelog filtering is in place, it's become evident that
naming the filters according to the set of revs _not_ included in the
filtered changelog is confusing. This is especially evident in the
collaborative branch cache scheme.

This changes the names of the filters to reflect the revs that _are_
included:

  hidden -> visible
  unserved -> served
  mutable -> immutable
  impactable -> base

repoview.filteredrevs is renamed to filterrevs, so that callers read a
bit more sensibly, e.g.:

  filterrevs('visible') # filter revs according to what's visible
2013-01-13 01:39:16 -06:00
Mads Kiilerich
3ab92babe1 clone: don't include empty revlogs in stream 2013-01-15 20:55:47 +01:00
Pierre-Yves David
cfd0b99b67 clfilter: drop extra filtering in wireprotocol
The repository used by wireprotocol is already filtered. We no
longer need to call special functions.
2013-01-06 04:36:30 +01:00
Pierre-Yves David
96045ebc98 clfilter: filter "unserved" on all wireprotocol command calls
This ensures that unserved changesets are not exposed through the
wire protocol.
2013-01-06 04:37:33 +01:00
Wagner Bruna
795c3947e9 wireproto: fix pushkey hook failure and output on remote http repo
Over http, a failed pushkey hook simply crashed the server, and
successful hook output was never sent to the client.
2012-10-15 18:37:34 -03:00
Thomas Arendsen Hein
41c1ca4d45 wireproto: workaround for yield inside try/finally incompatible with python2.4 2012-09-18 17:00:58 +02:00
Patrick Mezard
ed389c0023 wireproto: fix check-code.py breakage introduced by 6e0f31b6f59a 2012-09-15 08:38:02 +02:00
Bryan O'Sullivan
10380b320f wireproto: don't format a debug string inside a hot loop
This improves stream_out performance by about 5%.
2012-09-14 12:06:40 -07:00
Bryan O'Sullivan
55e3685d62 wireproto: bypass filechunkiter for small files when streaming
Merely creating and using a generator has a measurable impact,
particularly since the common case for stream_out is generators that
yield just once. Avoiding generators improves stream_out performance
by about 7%.
2012-09-14 12:05:37 -07:00
Bryan O'Sullivan
0b5b186a96 wireproto: don't audit local paths during stream_out
Auditing at this stage is both pointless (paths are already trusted by
the local repo) and expensive. Skipping the audits improves stream_out
performance by about 15%.
2012-09-14 12:05:12 -07:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Pierre-Yves David
a4bba98ab8 pushkey: add more verbose debug output regarding pushkey
Very few data are displayed now, making it hard to debug phases and obsolete
related issues.
2012-07-28 12:28:35 +02:00
Pierre-Yves David
afa28ff113 repo: move visibleheads and visiblebranchmap logic in discovery
They were previously inside the mercurial.phases module, but obsolete
logic will need them to exclude `extinct` changesets from pull and
push.

The proper and planned way to implement such filtering is still to apply a
changelog level filtering. But we are far to late in the cycle to implement and
push such a critical piece of code (changelog filtering). With Matt Mackall
approval I'm extending this quick and dirty mechanism for obsolete purpose.

Changelog level filtering should come during the next release cycle.
2012-07-17 01:22:31 +02:00
Peter Arrenbrecht
ef7b77046e peer: introduce real peer classes
This change separates peer implementations from the repository implementation.
localpeer currently is a simple pass-through to localrepository, except for
legacy calls, which have already been removed from localpeer. This ensures that
the local client code only uses the most modern peer API when talking to local
repos.

Peers have a .local() method which returns either None or the underlying
localrepository (or descendant thereof). Repos have a .peer() method to return
a freshly constructed localpeer. The latter is used by hg.peer(), and also to
allow folks to pass either a peer or a repo to some generic helper methods.
We might want to get rid of .peer() eventually.

The only user of locallegacypeer is debugdiscovery, which uses it to pose as a
pre-setdiscovery client. But we decided to leave the old API defined in
locallegacypeer for clarity and maybe for other uses in the future.

It might be nice to actually define the peer API directly in peer.py as stub
methods. One problem there is, however, that localpeer implements
lock/addchangegroup, whereas the true remote peers implement unbundle.
It might be desireable to get rid of this distinction eventually.
2012-07-13 21:47:06 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Pierre-Yves David
c37b1089b6 branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Discovery now use an overlay above branchmap to prune invisible "secret"
changeset from branchmap.

To minimise impact on the code during the code freeze, this is achieve by
recomputing non-secret heads on the fly when any secret changeset exists. This
is a computation heavy approach similar to the one used for visible heads. But
few sever should contains secret changeset anyway.  See comment in code for more
robust approach.

On local repo the wrapper is applied explicitly while the wire-protocol take
care of wrapping branchmap call in a transparent way. This could be unified by
the Peter Arrenbrecht and Sune Foldager proposal of a `peer` object.

An inappropriate `(+i heads)` may still appear when pushing new changes on a
repository with secret changeset. (see Issue3394 for details)
2012-04-24 16:32:44 +02:00
Pierre-Yves David
7d0ee06c06 wireprotocol: use visibleheads as reference while unbundling (issue 3303)
The `repo` object here is *always* local. Using `repo.heads()` ensure we will
reject push if any secret changeset exists.

During discovery, `visibleheads` were sent to the peer. So we can only expect it
to send us `visibleheads` back. If any secret changeset exists::

    visibleheads != repo.heads()

This fix server side part of issue 3303 when pushing over the wire.
2012-04-26 03:47:17 +02:00
Benoit Allard
ed90b14694 protocol: Add the stream-preferred capability
This makes the client use the uncompressed protocol.
2012-04-04 00:00:47 +02:00
Matt Mackall
464b6bafef wireproto: refuse to lookup secret csets 2012-01-18 20:00:48 -06:00
Pierre-Yves David
8abd0aa7c9 phases: do not exchange secret changesets
Any secret changesets will be excluded from pull and push. Phase data are
properly synchronized on pull and push if a changeset is seen as secret locally
but is non-secret remote side.

This patch does not handle the case of a changeset secret on remote but known
locally.
2011-12-22 00:42:25 +01:00
Pierre-Yves David
3f5fbfb66a wireproto: handle other server output in pushkey
Remote side may add useful information alongside failure return code. For
example "ssl is required". This patch mirror what is done for the unbundle
command.
2011-12-12 15:16:58 +01:00
Pierre-Yves David
5ac8c7b10a addchangegroup: remove the lock argument on the addchangegroup methods
This argument is no longer require. post lock release code is now handled with
dedicated post release callback code in lock itself.
2011-11-28 01:32:13 +01:00
Andreas Freimuth
5fe27df173 wireproto: do not call pushkey module directly (issue3041)
Call the repos pushkey/listkeys member function instead.
So the pushkey-hooks are triggered.
2011-10-10 13:52:54 +02:00
Andrew Pritchard
2d8acb3e0b wireproto: add out-of-band error class to allow remote repo to report errors
Older clients will still print the provided error message and not much else:
over ssh, this will be each line prefixed with 'remote: ' in addition to an
"abort: unexpected response: '\n'"; over http, this will be the '---%<---'
banners in addition to the 'does not appear to be a repository' message.

Currently, clients with this patch will display 'abort: remote error:\n' and
the provided error text, but it is trivial to style the error text however is
deemed appropriate.
2011-08-02 15:21:10 -04:00
Augie Fackler
1712535cb4 wireproto: use safehasattr or getattr instead of hasattr 2011-07-25 16:05:01 -05:00
Peter Arrenbrecht
32dcc012d5 wireproto: make a number of commands batchable
Makes lookup, heads, known, branchmap, pushkey, and listkeys batchable.
It could, for instance, be interesting to use this to batch calls to
lookup when a pull or clone has multiple --rev arguments. The next patch
is going to batch heads and known to slightly tune discovery.
2011-06-14 22:56:20 +02:00
Peter Arrenbrecht
0e9696a634 wireproto: add batching support to wirerepository
Adds the plumbing and wire call for batched execution, but does not
batch-enable any methods yet.
2011-06-14 22:52:58 +02:00
Peter Arrenbrecht
9870a43596 wireproto: add basic command batching infrastructure
Note that localbatch will not be used until we actually have a localpeer to
use it with.
2011-06-14 22:51:26 +02:00
Peter Arrenbrecht
8761d1fa87 wireproto: enable optional args for known() for future extensibility
Firstly, I think we should do this for all new wire commands, just
to be on the safe side. So I want to get this into the 1.9 release.

Secondly, there actually is potential here that sometimes the server
can know that the number of its nodes which can possibly still be
undecided on the client is small. It might then just send them along
directly (cutting short the end game). This, however, requires
walking the graph on the server, which can be expensive, so for the
moment we're not actually doing it.
2011-05-24 17:48:16 +02:00
Martin Geisler
34dddcd6fe wireproto: do not hash when heads == ['force']
Changeset 20b319765bcf introduced the unbundlehash capability and
unconditionally hashed the heads on the client side. By mistake, the
heads were also cased in the heads == ['force'] case.
2011-05-24 16:12:01 +02:00
Steven Brown
c1075f3880 httprepo: long arguments support (issue2126)
Send the command arguments in the HTTP headers. The command is still part
of the URL. If the server does not have the 'httpheader' capability, the
client will send the command arguments in the URL as it did previously.

Web servers typically allow more data to be placed within the headers than
in the URL, so this approach will:
- Avoid HTTP errors due to using a URL that is too large.
- Allow Mercurial to implement a more efficient wire protocol.

An alternate approach is to send the arguments as part of the request body.
This approach has been rejected because it requires the use of POST
requests, so it would break any existing configuration that relies on the
request type for authentication or caching.

Extensibility:
- The header size is provided by the server, which makes it possible to
  introduce an hgrc setting for it.
- The client ignores the capability value after the first comma, which
  allows more information to be included in the future.
2011-05-01 01:04:37 +08:00
Alexander Solovyov
0eb3836642 remove unused imports and variables 2011-04-30 13:59:14 +02:00
Peter Arrenbrecht
9855dca4f8 wireproto: add test for new optional arg missing on server
New argument is silently ignored by both HTTP and SSH servers.
This means we can, for instance, add new flags to getbundle()
to request advanced features (like lightweight-copy-aware bundles),
and older servers will silently ignore this request and send back
a plain bundle.
2011-04-29 14:54:01 +02:00
Shuhei Takahashi
ae68689a32 wireproto: allow unbundle with hashed heads parameter (issue2126)
Current wire protocol of unbundle sends the list of all heads in the remote
repository to avoid race condition.  This causes "URL too long" error on HTTP
server when the repository has many heads.

This change allows clients to send SHA1 hash of sorted head hashes instead.
Also, this introduces "unbundlehash" capability to inform them that the server
accepts hashed heads parameter.
2011-04-16 01:05:56 +09:00
Peter Arrenbrecht
6646f48826 wireproto: add getbundle() function
getbundle(common, heads) -> bundle

Returns the changegroup for all ancestors of heads which are not ancestors of common. For both
sets, the heads are included in the set.

Intended to eventually supercede changegroupsubset and changegroup. Uses heads of common region
to exclude unwanted changesets instead of bases of desired region, which is more useful and
easier to implement.

Designed to be extensible with new optional arguments (which will have to be guarded by
corresponding capabilities).
2011-03-23 16:02:11 +01:00
Matt Mackall
eec1a7b126 wireproto: avoid naked excepts 2011-03-22 21:26:19 -05:00
Peter Arrenbrecht
d542bac8c7 wireproto: add known([id]) function
known([Node]) -> [1/0]

Returns 1/0 for each node, indicating whether it's known by the server.
Needed for new discovery protocols introduced in later patches.
2011-03-22 09:22:21 +01:00
Peter Arrenbrecht
54d1d4736b wireproto: fix decodelist to properly return empty list
Needed by tests for next patch introducing known().
2011-03-22 07:40:02 +01:00
Peter Arrenbrecht
5925b26799 wireproto: fix handling of '*' args for HTTP and SSH 2011-03-22 07:38:32 +01:00
Peter Arrenbrecht
375ab88b9f debug: add debugwireargs to test argument passing over the wire
Tests argument passing locally, via HTTP, and via SSH. This is mainly preparation
for the next patch.
2011-03-22 07:38:32 +01:00
David Soria Parra
d4d13da65d wireproto: catch possible cast error in pushkey
The server can return an unexpected answer like 'ssl required'. We catch those
possible cast errors and abort the operation.
2011-02-21 00:37:55 +01:00
Matt Mackall
776084cff3 pushkey: use UTF-8 2010-11-28 18:21:47 -06:00
Matt Mackall
0d5b6162e5 wireproto: use proper UTF-8 handling for key lookup
Lookups happen in the local encoding space, but the wire protocol
should be using UTF-8 for interoperability.
2010-11-24 16:10:37 -06:00
Matt Mackall
8b31da4540 branch: operate on branch names in local string space where possible
Previously, branch names were ideally manipulated as UTF-8 strings,
because they were stored as UTF-8 in the dirstate and the changelog
and could not be safely converted to the local encoding and back.

However, only about 80% of branch name code was actually using the
right encoding conventions. This patch uses the localstr addition to
allow working on branch names as local strings, which simplifies
handling so that the previously incorrect code becomes correct.
2010-11-24 15:56:32 -06:00
Benoit Boissinot
16e11c728a wireproto: introduce pusherr() to deal with "unsynced changes" error
The behaviour between http and ssh still differ:
- the "unsynced changes" is seen as a remote output in the http cases
- but it is correctly seen as a push error for ssh
2010-10-11 12:45:36 -05:00
Benoit Boissinot
d2a82b6bc1 wireproto: redirect the output earlier 2010-10-11 12:44:33 -05:00
Benoit Boissinot
2a6248535c wireproto: return in finally was messing with the return inside the block 2010-10-11 12:44:11 -05:00
Matt Mackall
c2f36f74bb bundle: encapsulate all bundle streams in unbundle class 2010-09-20 14:32:21 -05:00
Sune Foldager
aca3a53bf9 clone: only use stream when we understand the revlog format
This patch fixes issues with stream cloning in the presense of parentdelta,
lwcopy and similar additions that change the interpretation of the revlog
format, or the format itself.

Currently, the stream capability is sent like this:
stream=<version of changelog>

But the client doesn't actually check the version number; also, it only checks
the changelog and it doesn't capture the interpretation-changes and
flag-changes in parentdelta and lwcopy.

This patch removes the 'stream' capability whenever we use a non-basic revlog
format, to prevent old clients from receiving incorrect data. In those cases,
a new capability called 'streamreqs' is added instead. Instead of a revlog
version, it comes with a list of revlog-format relevant requirements, which
are a subset of the repository requirements, excluding things that are not
relevant for stream.

New clients use this to determine whether or not they can stream. Old clients
only look for the 'stream' capability, as always. New servers will still send
this when serving old repositories.
2010-09-15 11:06:22 +02:00
Martin Geisler
80db87965d Consistently import foo as foomod when foo to avoid shadowing
This is in the style of 1aaceccaf1dc.
2010-08-30 14:38:24 +02:00
Brodie Rao
0f9d940cb9 cleanup: remove unused variables 2010-08-27 13:32:40 -04:00
Matt Mackall
ee35426eda bundle: unify/refactor unbundle/readbundle 2010-08-25 15:33:06 -05:00
Benoit Boissinot
15d634f7a0 fix undefined variables, spotted by pylint 2010-08-15 11:05:04 +02:00
Dirkjan Ochtman
2c0f8ea6a7 protocol: move the streamclone implementation into wireproto 2010-07-20 20:52:23 +02:00
Dirkjan Ochtman
bfec66d497 protocol: wrap non-string protocol responses in classes 2010-07-20 20:53:33 +02:00
Dirkjan Ochtman
d80015833d protocol: extract compression from streaming mechanics 2010-07-16 22:20:10 +02:00
Dirkjan Ochtman
3e08fe969b protocol: rename send methods to get grouping by prefix 2010-07-16 18:18:35 +02:00
Dirkjan Ochtman
3f725ce532 protocol: do not translate error messages on the remote side 2010-07-16 23:02:46 +02:00
Dirkjan Ochtman
05df6236b1 protocol: use return shortcut instead of respond function 2010-07-16 19:02:30 +02:00
Dirkjan Ochtman
1a4105fea1 protocol: command must be checked before passing in 2010-07-16 19:01:34 +02:00
Benoit Boissinot
9f2b90070b wireproto: refactor list of nodeid encoding / decoding 2010-07-16 00:52:13 +02:00
Matt Mackall
0cc5d56580 protocol: unify server-side capabilities functions 2010-07-15 13:56:52 -05:00
Matt Mackall
a6024ca63a protocol: unify unbundle on the server side 2010-07-15 11:24:42 -05:00
Matt Mackall
d46a89387f protocol: unify client unbundle support
- introduce _callpush helper
- factor out differences in result handling into helpers
- unify
2010-07-14 17:12:18 -05:00
Matt Mackall
8c936882a2 protocol: unify client changegroup methods 2010-07-14 17:09:31 -05:00
Matt Mackall
60b140435c protocol: unify stream_out client code 2010-07-14 16:55:44 -05:00
Matt Mackall
fcb8f496e2 protocol: unify basic http client requests 2010-07-14 16:35:51 -05:00
Matt Mackall
0b86557977 protocol: move basic ssh client commands to wirerepository 2010-07-14 16:34:57 -05:00
Matt Mackall
47c6d08427 protocol: unify stream_out command 2010-07-14 16:19:27 -05:00
Matt Mackall
050367f581 protocol: unify changegroup commands
- add sendchangegroup protocol helpers
- handle commands with None results
- move changegroup commands into wireproto.py
2010-07-14 15:43:20 -05:00
Matt Mackall
76d9ad7fea protocol: add proto to method prototypes 2010-07-14 15:33:21 -05:00
Matt Mackall
224bed3afd protocol: introduce wireproto.py
- add a protocol-independent dispatcher
- move most of the basic commands from sshserver to wireproto
- dispatch through wireproto first
2010-07-14 15:25:15 -05:00