Commit Graph

240 Commits

Author SHA1 Message Date
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