Mercurial > hg-stable
view CONTRIBUTING @ 37629:fa0382088993
repository: define new interface for running commands
Today, the peer interface exposes methods for each command that can
be executed. In addition, there is an iterbatch() API that allows
commands to be issued in batches and provides an iterator over the
results. This is a glorified wrapper around the "batch" wire command.
Wire protocol version 2 supports nicer things (such as batching
any command and out-of-order replies). It will require a more
flexible API for executing commands.
This commit introduces a new peer interface for making command
requests. In the new world, you can't simply call a method on the
peer to execute a command: you need to obtain an object to be used
for executing commands. That object can be used to issue a single
command or it can batch multiple requests. In the case of full duplex
peers, the command may even be sent out over the wire immediately.
There are no per-command methods. Instead, there is a generic
method to call a command. The implementation can then perform domain
specific processing for specific commands. This includes passing
data via a specially named argument.
Arguments are also passed as a dictionary instead of using **kwargs.
While **kwargs is nicer to use, we've historically gotten into
trouble using it because there will inevitably be a conflict between
the name of an argument to a wire protocol command and an argument
we want to pass into a function.
Instead of a command returning a value, it returns a future which
will resolve to a value. This opens the door for out-of-order
response handling and concurrent response handling in the version
2 protocol.
Differential Revision: https://phab.mercurial-scm.org/D3267
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 13 Apr 2018 10:23:05 -0700 |
parents | a492610a2fc1 |
children |
line wrap: on
line source
Our full contribution guidelines are in our wiki, please see: https://www.mercurial-scm.org/wiki/ContributingChanges If you just want a checklist to follow, you can go straight to https://www.mercurial-scm.org/wiki/ContributingChanges#Submission_checklist If you can't run the entire testsuite for some reason (it can be difficult on Windows), please at least run `contrib/check-code.py` on any files you've modified and run `python contrib/check-commit` on any commits you've made (for example, `python contrib/check-commit 273ce12ad8f1` will report some style violations on a very old commit).