Commit Graph

26 Commits

Author SHA1 Message Date
Augie Fackler
af1601947d wireproto: make iterbatcher behave streamily over http(s)
Unfortunately, the ssh and http implementations are slightly different
due to differences in their _callstream implementations, which
prevents ssh from behaving streamily. We should probably introduce a
new batch command that can stream results over ssh at some point in
the near future.

The streamy behavior of batch over http(s) is an enormous win for
remotefilelog over http: in my testing, it's saving about 40% on file
fetches with a cold cache against a server on localhost.
2016-03-01 18:41:43 -05:00
Bryan O'Sullivan
5ea0fa6c09 sshpeer: make remotelock a context manager 2016-01-15 13:14:50 -08:00
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Gregory Szorc
1251142350 sshpeer: use absolute_import 2015-08-08 19:55:01 -07:00
Pierre-Yves David
9e33e7774c sshpeer: also use doublepipe for client to server communication
This will allow even more real time output when the server issue output in the
middle a stream push.
2015-05-20 11:55:59 -05:00
Pierre-Yves David
69155bf9f2 sshpeer: allow doublepipe on unbuffered main pipe
The output pipe does not have manually managed read buffer (actually, no read
anything). To also use the doublepipe for outgoing write (useful to consume
remote output when pushing large set of data) we need the doublepipe to work on
standard pipe too.
2015-06-05 04:54:23 -07:00
Pierre-Yves David
6a2621d0a1 sshpeer: allow write operations through double pipe
We have a shiny toy, lets make it wider.
2015-05-20 10:58:29 -05:00
Pierre-Yves David
25d5d30d03 sshpeer: rename 'size' to 'data' in doublepipe
We are about to add 'write' support, the argument will be either an int or a
string.
2015-05-20 17:40:47 -05:00
Pierre-Yves David
b4290f7a14 sshpeer: use the doublepipe object for the server to client channel
This restores real-time output from ssh server while waiting for protocol data
sent by the server.
2015-05-20 11:41:48 -05:00
Pierre-Yves David
fdc193e836 sshpeer: introduce a "doublepipe" class
This class is responsible for ensuring we still process the server output
streamed through the ssh's 'stderr' pipe during the initial wait for other
protocol streams.

It currently only works on posix system because of its use of 'select.select'.
2015-05-22 10:48:11 -05:00
Pierre-Yves David
e6518023e3 sshpeer: run the ssh command unbuffered
This is necessary to use non-blocking IO base on polling. Such polling is
needed to restore real time output with ssh peer.

Changeset 6a565336bae3 is talking about 5x regression on Mac OS X when playing
with this value. So we introduced our own buffering layer in previous
changesets. This seems to keep the regression away (we are even issuing much
less read).
2015-05-20 11:31:38 -05:00
Pierre-Yves David
de72eff352 sshpeer: use a 'bufferedinputpipe' for standard output of the ssh process
We need this pipe to still be buffered when will switch to unbuffered pipe.
(switch motivated by the need of using polling to restore real time output from
ssh server). This is the only pipe that needs to be wrapped because this is the
one who do extensive usage of 'readline'. The stderr pipe of the process is
alway read in non blocking raw chunk, so it won't benefit from the
buffering.
2015-05-31 00:00:36 -07:00
Pierre-Yves David
c899dea3d5 sshpeer: extract the forward output logic
We are about to make a more aggressive use of this when reading and writing on
the other pipes. We it needs to be reusable.
2015-05-18 23:19:11 -05:00
Pierre-Yves David
b51b0deda6 sshpeer: break "OutOfBandError" feature for ssh (BC)
When we'll be using the ssh's 'stderr' for realtime output successfully, it will
no longer be possible to use 'stderr' to carry the error message (because it
is already consumed by the real time output logic.

This feature is very rarely used (test says largefile only) and I think
breaking its output pattern is worth the benefit of having real time output with
ssh.
2015-05-20 12:33:12 -05:00
Matt Mackall
3406ce4956 merge with stable 2014-12-29 16:39:20 -06:00
Matt Mackall
bf17f56a67 sshpeer: more thorough shell quoting
This fixes an issue spotted by Jesse Hertz.
2014-12-29 14:27:02 -06:00
Yuya Nishihara
ceda6fbba9 util.system: use ui.system() in place of optional ui.fout parameter 2014-11-08 13:06:22 +09:00
Yuya Nishihara
187868d5fe sshpeer: forward stdout of remote "hg init" to appropriate output channel
Otherwise, commandserver channel could be corrupted.
2014-10-14 21:59:39 +09:00
Gregory Szorc
db57d5e9d6 platform: implement readpipe()
Reading all available data from a pipe has a platform-dependent
implementation.

This patch establishes platform.readpipe() by copying the
inline implementation in sshpeer.readerr(). The implementations
for POSIX and Windows are currently identical. The POSIX
implementation will be changed in a subsequent patch.
2014-08-15 20:02:18 -07:00
Pierre-Yves David
1383ee8462 sshpeer: add implementation of _calltwowaystream
This implements the call needed by bundle2. The error handling is a bit flaky
right now, but bundle2 error handling in general is still flaky anyway. Bundle2
is still disabled by default, I do not expect this to be a problem.
2014-04-15 17:18:35 -04: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
Siddharth Agarwal
1c5bc58f8f sshpeer: only print out 'running ssh' messages in debug mode (BC)
Previously, if another command was run with --verbose, and for whatever reason
that invoked sshpeer, we'd get a 'running ssh' message from sshpeer. This extra
line would interfere with that command's output and cause dumb parsers to
break.

For example, hg annotate can be run with --verbose to get full usernames. This,
combined with the third-party remotefilelog extension which can cause ssh
connections to be created, leads to an extra 'running ssh' line that breaks
most parsers.

This patch is (BC) because hg pull --verbose will no longer print out exactly
what ssh command it is running.

No tests are affected by this change.
2014-03-18 13:40:03 -07:00
Matt Mackall
796c64f268 sshpeer: mark _validrepo internal 2013-07-16 11:18:16 -05:00
Durham Goode
97bdc357fb sshpeer: store subprocess so it cleans up correctly
When running 'hg pull --rebase', I was seeing this exception 100% of the
time as the python process was closing down:

Exception TypeError: TypeError("'NoneType' object is not callable",) in
<bound method Popen.__del__ of <subprocess.Popen object at 0x937c10>> ignored

By storing the subprocess on the sshpeer, the subprocess seems to clean up
correctly, and I no longer see the exception. I have no idea why this actually
works, but I get a 0% repro if I store the subprocess in self.subprocess,
and a 100% repro if I store None in self.subprocess.

Possibly related to issue 2240.
2013-03-08 16:59:36 -08: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