Commit Graph

276 Commits

Author SHA1 Message Date
Augie Fackler
d19fbe9c1b merge with stable 2017-02-15 11:22:01 -05:00
Siddharth Agarwal
7d1a6f9777 bundle2: fix assertion that 'compression' hasn't been set
`n.lower()` will return `compression`, not `Compression`.
2017-02-13 11:43:12 -08:00
Gregory Szorc
9efea3d15c bundle2: allow compression options to be passed to compressor
Compression engines allow options to be passed to them to control
behavior. This patch exposes an argument to bundle2.writebundle()
that passes options to the compression engine when writing compressed
bundles. The argument is honored for both bundle1 and bundle2, the
latter requiring a bit of plumbing to pass the value around.
2017-01-10 11:19:37 -08:00
Pierre-Yves David
683feeeddd bundle2: implement a basic __repr__ for bundle2 part
We display basic data as the part id and part type. This make debugging bundle2
related code friendlier.
2017-02-02 14:19:48 +01:00
Pierre-Yves David
24dbeff39a bundle2: drop an outdated comment
The function is no longer in "early" stage and have been used in production for
years. We can probably drop that part of the docstring...
2017-02-02 11:03:41 +01:00
Gregory Szorc
2e5ba752dd bundle2: equate 'UN' with no compression
An upcoming patch will change the "alg" argument passed to this
function from None to "UN" when no compression is wanted.

The existing implementation of bundle2 does not set a "Compression"
parameter if no compression is used. In theory, setting
"Compression=UN" should work. But I haven't audited the code to see if
all client versions supporting bundle2 will accept this.

Rather than take the risk, avoid the BC breakage and treat "UN"
the same as None.
2016-11-10 23:29:01 -08:00
Gregory Szorc
ddaa837b1a bundle2: use compressstream compression engine API
Compression engines now have an API for compressing a stream of
chunks. Switch to it and make low-level compression code disappear.
2016-11-07 18:46:37 -08:00
Gregory Szorc
e1a5352aa0 bundle2: use compression engines API to obtain decompressor
Like the recent change for the compressor side, this too is
relatively straightforward. We now store a compression engine
on the instance instead of a low-level decompressor. Again, this
will allow us to easily transition to different compression engine
APIs when they are implemented.
2016-11-07 18:36:48 -08:00
Gregory Szorc
1ddbc0cc5d bundle2: use new compression engine API for compression
Now that we have a new API to define compression engines, let's put it
to use!

The new code stores a reference to the compression engine instead of
a low-level compressor object. This will allow us to more easily
transition to different APIs on the compression engine interface
once we implement them.

As part of this, we change the registration in bundletypes to use 'UN'
instead of None. Previously, util.compressors had the no-op compressor
registered under both the 'UN' and None keys. Since we're switching to
a new API, I don't see the point in carrying this dual registration
forward.
2016-11-07 18:35:43 -08:00
Gregory Szorc
d694855e6f bundle2: only emit compressed chunks if they have data
This is similar to 72dcaa40df76. Not all calls into the compressor
return compressed data, as the compressor may buffer compressed
output internally. It is cheaper to check for empty chunks than to
send empty chunks through the generator.

When generating a gzip-v2 bundle of the mozilla-unified repo, this
change results in 50,093 empty chunks not being sent through the
generator (out of 1,902,996 total input chunks).
2016-10-15 17:10:53 -07:00
Yuya Nishihara
7c03e0d6ba pycompat: provide 'ispy3' constant
We compare version_info at several places, which seems enough to define
a constant.
2016-09-28 20:01:23 +09:00
Pierre-Yves David
5bcff70a60 merge with stable 2016-09-14 17:12:39 +02:00
Akihiko Odaki
82bf519632 bundle2: localize handleoutput remote prompts
Code archaeology suggests that there was no good reason for this not to
be localized. 'remote: ' is already localized elsewhere.
2016-09-01 13:16:55 -05:00
Gregory Szorc
c48909f844 bundle2: fail faster when interrupted
Before this patch, bundle2 application attempted to consume remaining
bundle2 part data when the process is interrupted (SIGINT) or when
sys.exit is called (translated into a SystemExit exception). This
meant that if one of these occurred when applying a say 1 GB
changegroup bundle2 part being downloaded over a network, it may take
Mercurial *several minutes* to terminate after a SIGINT because the
process is waiting on the network to stream megabytes of data. This is
not a great user experience and a regression from bundle1. Furthermore,
many process supervisors tend to only give processes a finite amount of
time to exit after delivering SIGINT: if processes take too long to
self-terminate, a SIGKILL is issued and Mercurial has no opportunity to
clean up. This would mean orphaned locks and transactions. Not good.

This patch changes the bundle2 application behavior to fail faster
when an interrupt or system exit is requested. It does so by not
catching BaseException (which includes KeyboardInterrupt and
SystemExit) and by explicitly checking for these conditions in
yet another handler which would also seek to the end of the current
bundle2 part on failure.

The end result of this patch is that SIGINT is now reacted to
significantly faster: the active transaction is rolled back
immediately without waiting for incoming bundle2 data to be consumed.
This restores the pre-bundle2 behavior and makes Mercurial treat
signals with the urgency they deserve.
2016-08-25 19:53:14 -07:00
Gregory Szorc
4ad5f2e492 bundle2: store changeset count when creating file bundles
The bundle2 changegroup part has an advisory param saying how many
changesets are in the part. Before this patch, we were setting
this part when generating bundle2 parts via the wire protocol but
not when generating local bundle2 files.

A side effect of not setting the changeset count part is that progress
bars don't work when applying changesets. As the tests show, this
impacted clone bundles, shelve, backup bundles, `hg unbundle`, and
anything touching bundle2 files.

This patch adds a backdoor to allow us to pass state from
changegroup generation into the unbundler. We store the number
of changesets in the changegroup in this state and use it to
populate the aforementioned advisory part parameter when generating
the bundle2 bundle.

I concede that I'm not thrilled by how state is being passed in
changegroup.py (it feels a bit hacky). I would love to overhaul the
rather confusing set of functions in changegroup.py with something that
passes rich objects around instead of e.g. low-level generators.
However, given the code freeze for 3.9 is imminent, I'd rather not
undertake this endeavor right now. This feels like the easiest way
to get the parameter added to the changegroup part.
2016-07-17 15:13:51 -07:00
Gregory Szorc
71e33a969a bundle2: use a sorted dict for holding parameters
An upcoming change that introduces a 2nd part parameter to a part
reveals that `hg debugbundle` isn't deterministic because parameters
are stored on n plain, unsorted dict.

While we could change that command to sort before output, I think
the more important underlying issue is that bundle2 reading is taking
an ordered data structure and converting it to an unordered one.
Plugging in util.sortdict() fixes that problem while preserving API
compatibility.

This patch also appears to shine light on the fact that we don't
have tests verifying parts with multiple parameters roundtrip
correctly. That would be a good thing to test (and fuzz)... someday.
2016-07-17 14:51:00 -07:00
Mads Kiilerich
f1004d7ba4 bundle2: don't assume ordering of heads checked after push
Usually, the heads will have the same ordering in handlecheckheads. Insisting
on the same ordering is however an unnecessary constraint that in some custom
cases can cause pushes to fail even though the actual heads didn't change. This
caused production issues for us in combination with the current version of
https://bitbucket.org/Unity-Technologies/hgwebcachingproxy/ .
2016-06-01 21:40:52 +02:00
Pulkit Goyal
9d5cc65520 py3: conditionalize the raise statement
raise E,V,T is not acceptable in Python 3, thats is conditionalized.
Moreover this will result in syntax error so we have to use exec() to
execute this. Related PEP- https://www.python.org/dev/peps/pep-3109/#id14

My implementation is motivated from the six implementation except they are
defining a new function exec_() to prevent adding an extra frame AFAIK :)

https://bitbucket.org/gutworth/six/src/ca4580a5a648/six.py#six.py-680
2016-08-08 23:51:11 +05:30
timeless
109fcbc79e pycompat: switch to util.urlreq/util.urlerr for py3 compat 2016-04-06 23:22:12 +00:00
Martin von Zweigbergk
d613237780 bundle: remove obsolete (and duplicate) comment
Change 760f9c8ad835 (changegroup: move chunk extraction into a
getchunks method of unbundle10, 2014-04-10) extracted some code to a
getchunks() method and copied a comment about the changegroup format
to the new method. The copy that remains in the old place, doesn't
make much sense there, so let's remove it.
2016-03-29 10:21:05 -07:00
Martin von Zweigbergk
4cc86f7b27 bundle: move writebundle() from changegroup.py to bundle2.py (API)
writebundle() writes a bundle2 bundle or a plain changegroup1. Imagine
away the "2" in "bundle2.py" for a moment and this change should makes
sense. The bundle wraps the changegroup, so it makes sense that it
knows about it. Another sign that this is correct is that the delayed
import of bundle2 in changegroup goes away.

I'll leave it for another time to remove the "2" in "bundle2.py"
(alternatively, extract a new bundle.py from it).
2016-03-28 14:41:29 -07:00
Martin von Zweigbergk
86ca76bafe changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
In b89de5ee5b31 (changegroup: don't support versions 01 and 02 with
treemanifests, 2016-01-19), I stopped supporting use of cg1 and cg2
with treemanifest repos. What I had not considered was that it's
perfectly safe to pull *to* a treemanifest repo using any changegroup
version. As reported in issue5066, I therefore broke pull from old
repos into a treemanifest repo. It was not covered by the test case,
because that pulled from a local repo while enabling treemanifests,
which enabled treemanifests on the source repo as well. After
switching to pulling via HTTP, it breaks.

Fix by splitting up changegroup.supportedversions() into
supportedincomingversions() and supportedoutgoingversions().
2016-01-27 09:07:28 -08:00
Augie Fackler
54446bb7e0 cleanup: use modern @property/@foo.setter property specification
We can use this now that we're 2.6+, and this is more idiomatic modern
Python.
2016-01-16 10:50:28 -05:00
Martin von Zweigbergk
e5bd6473b3 changegroup: hide packermap behind methods
This is to prepare for hiding changegroup3 behind a config option.
2016-01-12 21:01:06 -08:00
Martin von Zweigbergk
417363259e treemanifests: set bundle2 part parameter indicating treemanifest
By adding a mandatory 'treemanifest' parameter in the bundle2 part, we
make it possible for the recipient to set repo requirements before the
manifest revlog is accessed.
2016-01-08 21:13:06 -08:00
Gregory Szorc
059667a51c bundle2: attribute remote failures to remote (issue4788)
Before bundle2, hook output from hook failures was prefixed with
"remote: ". Up to this point with bundle2, the output was converted to
the message to print in an Abort exception. This had 2 implications:

1) It was unclear whether an error message came from the local repo
   or the remote
2) The exit code changed from 1 to 255

This patch changes the handling of error:abort bundle2 parts during push
to prefix the error message with "remote: ". This restores the old
behavior.

We still preserve the behavior of raising an Abort during bundle2
application failure. This is a regression from pre-bundle2 because the
exit code changed.

Because we no longer raise an Abort with the remote's message, we needed
to insert a message for the new Abort. So, I invented a new error
message for that. This is another change from pre-bundle2. However, I
like the new error message because it states unambiguously who aborted
the push failed, which I think is important for users so they can decide
what's next.
2015-10-24 00:39:22 +01:00
Pierre-Yves David
2468be2e78 bundle2: make unbundle.compressed return True when compressed
We were returning 'False' in all cases, even when the bundle2 was actually
compressed.
2015-10-02 23:21:39 -07:00
Pierre-Yves David
fb85c76c3c applybundle: take url as argument
We allow specifying the url to carry it to hooks. This gets us closer to
'bundle1.apply(...)' and will allow us to remove regressions in multiple place
where we forget to pass the url to hooks.
2015-10-20 15:55:04 +02:00
Pierre-Yves David
737d464351 applybundle: take source as argument
We allow specifying the source to carry it to hooks. This gets us closer to
'bundle1.apply(...)' and will allow us to remove regressions in multiple places
where we forget to pass the source to hooks.
2015-10-20 15:52:42 +02:00
Pierre-Yves David
a8f2963ec8 applybundle: set 'bundle2=1' env for all transaction
This should be set for all bundle2 application, we enforce that at a low level.
This is for courtesy with hooks.
2015-10-20 15:48:24 +02:00
Pierre-Yves David
bffc6ff104 bundle2: introduce an "applybundle" function
There is a case where the intent is clear and the transaction is not optional. We
want to be able to alter that transaction in a wide and easy way. We cannot get
a unified '.apply(repo)' method for bundle1 and bundle2 yet because the api are
still a bit too far apart. But this is a good step forward to get the rc out.
2015-10-20 15:45:39 +02:00
Augie Fackler
b9b5df0ea1 bundle2: use cg?unpacker.apply() instead of changegroup.addchangegroup() 2015-10-13 17:11:52 -04:00
Pierre-Yves David
e5984e269f bundle2: gracefully skip 'obsmarkers' part if evolution is disabled
We would skip the part if it was fully unknown, so we should also skip it if we
know we won't be able to apply it. This will allow us to produce bundles with
obsolescence markers alongside changegroup while still being able to apply them
on any client.
2015-10-15 03:29:00 +01: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
Durham Goode
b5e2c4fade bundle2: add op.gettransaction() to handlers that need the lock
A future patch will allow the bundle2 lock be taken lazily. We need to
introduce transaction-gets to each handler that needs the lock.

The tests caught these issues when I added lazy locking.
2015-10-06 14:42:29 -07:00
Pierre-Yves David
84d5d1a440 bundle2: add a way to just forward the bundle2 stream to another user
There is use case for directly forward and bundle2 stream from the peer to a
file (eg: 'hg incoming --bundle'), However ssh peers have no way to know the
'getbundle' is over except for actually interpreting the bundle. So we need to
have the unbundle do the interpreting and forward job.

The function is marked as private to highlight that this is terrible and that we
are sorry.
2015-10-08 01:40:21 -07:00
Pierre-Yves David
9cadff52d0 bundle2: split parameter retrieval and processing
We want to introduce a simple way to forward the content of a bundle2 stream.
For this purpose, we will need to both yield the parameters block and process it
(to apply any behavior change it might indicate).
2015-10-05 01:10:49 -07:00
Pierre-Yves David
c4198a6645 bundle2: allow compressed bundle
This changeset adds support for a 'compression' parameter in bundle2 streams.
When set, it controls the compression algorithm used for the payload part of the
bundle2.

There is currently no usage of this except in tests.
2015-09-23 12:56:12 -07:00
Pierre-Yves David
c6b4571453 bundle20: extract core payload generation in its own function
We are about to allow compressing the core of the bundle2. So we extract the
generation of this bits in its own parts to make this compression phases easier
in a later changesets.
2015-09-23 12:56:05 -07:00
Pierre-Yves David
18caca2d9c unbundle20: allow registering handlers for stream level parameters
As a comment in the code have been asking for, it is now possible to register
piece of code that handle parameters for the stream. I've been wondering is such
function should be class methods or not. I eventually went for externally
decorated methods to stick with the culture of extensibility from an extensions
that apply to bundle2.
2015-09-23 14:00:16 -07:00
Pierre-Yves David
2aa8064fde bundle2: rename error exception class for unsupported feature
The original name explicitly mention "Part", however it is also used outside of
parts related feature. We rename from 'UnsupportedPartError' to
'BundleUnknownFeatureError' to fix this.
2015-09-23 11:44:52 -07:00
Pierre-Yves David
a9d2d02aff bundle: use None when unpacking uncompressed changegroup
Let's be more modern!
2015-09-11 17:05:46 -07:00
Augie Fackler
b9db4815ce bundle2: don't try to recover from a GeneratorExit (issue4785)
GeneratorExit means the other end of the conversation has already
stopped listening, so don't try and yield out error
information. Instead, just let the GeneratorExit propagate normally.

This should resolve esoteric issues observed with servers that have
aggressive timeouts waiting for data to send to clients logging
internal Python errors[0]. This has been observed with both gunicorn's
gevent worker model and with scm-manager's built-in webserver (which
itself is something sitting inside jetty.)


0: Exception RuntimeError: 'generator ignored GeneratorExit' in <generator object getchunks at 0x7fd2f6c586e0> ignored
2015-09-01 15:47:33 -04:00
Gregory Szorc
5f5a2cec0b bundle2: use absolute_import 2015-08-07 19:54:08 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Gregory Szorc
0648c6a2bf bundle2: reword debug message for invalid .hgtags data
marmoute requested a follow-up to make the verb the first word.
2015-06-20 18:03:38 -07:00
Pierre-Yves David
0cb42d22dd bundle2.getunbundler: rename "header" to "magicstring"
This is more consistent with the name used in the bundler class. Thanks goes to
Martin von Zweigbergk for pointing this out.
2015-04-07 14:14:27 -07:00
Pierre-Yves David
450e786289 bundle2: provide number of changesets information to 'addchangegroup'
We can now link the two efforts and provided more useful information when
pulling changesets.
2015-06-07 15:57:54 -07:00
Martin von Zweigbergk
822059f89e bundle2: clarify in docstring that header size is for a single header
The docstring for the header size field currently says "The total
number of Bytes used by the part headers", but the size is about a
single header, so let's change it to "header".
2015-06-10 14:49:27 -07:00
Martin von Zweigbergk
57c8dc6ee0 bundle2: rename duplicate handlepushkeyreply to handleobsmarkerreply
The function was only called through the parthandlermapping dict, so
it was confusing but safe in practice.
2015-06-10 14:47:24 -07:00
Pierre-Yves David
e567efc154 bundle2: convey PushkeyFailed error over the wire
We add a way to convey the precise exception. This will allow better error
message on the server.
2015-06-10 13:10:53 -04:00
Pierre-Yves David
b5e74719f4 bundle2: also capture reply capability on failure
When unbundling over the wire is aborted, we have a mechanism to convey the
error inside a bundle part. As we add support for more errors, we need to know if
the client will support them. For this purpose, we duck punch the reply
capabilities of the client on the raised extensions.

This is similar to what is done to salvage the server output on error.
2015-06-06 00:50:27 -07:00
Pierre-Yves David
8956fcc604 bundle2: add an 'error' capability
This capability will be extended as new error type is introduced.
2015-06-06 00:32:19 -07:00
Pierre-Yves David
4386f8310a bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
The pushkey code is generic and the server side has little context on what the
client is trying to achieve. Generating interesting error messages server side
would be challenging. Instead we introduce a dedicated exception that carries more
data. In particular, it carries the id of the part which failed that will allow
clients to display custom error messages depending on the part intent.

The processing and transfer-over-the-wire of this exception is to be implemented
in coming changesets.
2015-05-27 23:48:54 -07:00
Pierre-Yves David
2f30e7a692 bundle2: abort when a mandatory pushkey part fails
So far, result of a pushkey operation had no consequence on the transaction
(beside the change). We makes it respect the 'mandatory' flag of part so that
failed pushkey call abort the whole transaction. This will allow rejecting
changes (primary target: changesets) regarding phases or bookmark criteria in
the future (when we will push such data in a mandatory part).

We currently raise an abort error because all clients support it. We'll
introduce a more precise error in the next changesets.
2015-05-27 05:28:40 -07:00
Gregory Szorc
a7e363e0cf bundle2: part handler for processing .hgtags fnodes mappings
.hgtags fnodes cache entries can be expensive to compute, especially
if there are hundreds of even thousands of them. This patch implements
support for receiving a bundle2 part that contains a mapping of
changeset to .hgtags fnodes.

An upcoming patch will teach the server to send this part, allowing
clients to bypass having to redundantly compute these values.

A number of tests changed due to the client advertising the "hgtagsfnodes"
capability.
2015-06-01 20:23:22 -07:00
Pierre-Yves David
d0e8796a75 bundle2: hide bundle2 stream debug under a config flag
The old output is very verbose and unsuitable for general debug level. It is
however very useful for debugging bundle2 generation or consumption issues. All
this verbose ouput is hidden under a 'devel.bundle2.debug' flag.
2015-05-26 23:06:17 -07:00
Pierre-Yves David
7d33b04271 bundle2: add generic debug output regarding processed interruption
If we are about to hide the detailed debug output, we need some generic debug
message to replace it in a concise way.
2015-05-26 23:47:19 -07:00
Pierre-Yves David
397fb0efd5 bundle2: add generic debug output regarding processed part payload
If we are about to hide the detailed debug output, we need some generic debug
message to replace it in a concise way.
2015-05-26 23:58:38 -07:00
Pierre-Yves David
977711b858 bundle2: add generic debug output regarding processed part
If we are about to hide the detailed debug output, we need some generic debug
message to replace it.
2015-05-26 23:36:31 -07:00
Pierre-Yves David
f4b0d8312f bundle2: add generic debug output at the end of bundle processing
If we are about to hide the detailed debug output, we need some generic debug
message to replace it in a concise way.
2015-05-27 00:02:49 -07:00
Pierre-Yves David
2d056781e3 bundle2: add generic debug output regarding processed bundle
If we are about to hide the detailed debug output, we need some generic debug
message to replace it in a concise way.
2015-05-27 00:00:35 -07:00
Pierre-Yves David
323fbad9e5 bundle2: add generic debug output regarding generated interruption
If we are about to hide the detailed debug output, we need some generic debug
message to replace it in a concise way.
2015-05-27 00:22:29 -07:00
Pierre-Yves David
aca59375f8 bundle2: add generic debug output regarding generated parts
If we are about to hide the detailed debug output, we need some generic debug
message to replace it in a concise way.
2015-05-27 00:19:16 -07:00
Pierre-Yves David
2aa990e3f6 bundle2: add generic debug output regarding generated bundle
If we are about to hide the detailed debug output, we need some generic debug
message to replace it in a more compact way.
2015-05-27 00:10:30 -07:00
Pierre-Yves David
669aff65a4 bundle2: add debug output for part generation
The part generation process was lacking a ui object and could not produce debug
output. It seems valuable to have some debug output on this part too, especially
now that we are planning to be able to hide it in the default --debug output.
2015-05-27 00:52:01 -07:00
Pierre-Yves David
803290608b bundle2: handle new line in 'indebug' function
Now that we have a prefix, it make sense to assume all output will be on a
single line.
2015-05-26 23:01:39 -07:00
Pierre-Yves David
91f110738d bundle2: prefix all unbundling debug message with 'bundle2-input:'
This make the origin of the message more explicit.
2015-05-26 20:40:21 -07:00
Pierre-Yves David
57e3ddc76b bundle2: introduce a specific function for debug messages while unbundling
The bundling process is very verbose, we would like to be able to hide such
output behind a configuration flag and have it more explicitly referencing
bundle2. The first step is to gather all these messages in a dedicated function.
2015-05-26 22:48:52 -07:00
Pierre-Yves David
b6c9526df1 bundle2: add an informative comment to the capability dict
It is fairly easy to get confused by capabilities "missing" from this dict. We
make it clear the dict is not the whole story.
2015-05-28 10:00:22 -07:00
Pierre-Yves David
01590fd818 bundle2: handle new line in 'outdebug' function
Now that we have a prefix, it make sense to assume all output will be on a
single line.
2015-05-26 23:02:19 -07:00
Pierre-Yves David
106d2910c2 bundle2: prefix all bundling debug messages with 'bundle2-ouput:'
This makes the origin of the message more explicit.
2015-05-26 22:57:35 -07:00
Pierre-Yves David
6a3212b3f4 bundle2: introduce a specific function for bundling debug message
The bundling process is very verbose, we would like to be able to hide such
output behind a configuration flag and have it more explicitly referencing
bundle2. The first step is to gather all these messages in a dedicated
function.

The same gathering will be later do for debug message issue by unbundling.
2015-05-26 22:49:03 -07:00
Pierre-Yves David
886a130d51 bundle2: use BaseException in bundle2
We can ensure we fail over properly in more cases.
2015-05-18 13:23:14 -05:00
Pierre-Yves David
e5b26a2e94 bundle2: disable ouput capture unless we use http (issue4613 issue4615)
The current bundle2 processing was capturing all output. This is nice as it
provide better meta data about what output what, but this was changing two
things:

1) adding a prefix "remote: " to "other" output during local push (issue4613)
2) local and ssh push does not provide real time output anymore (issue4615)

As we are unsure about what form should be used in (1) and how to solve (2) we
disable output capture in this two cases. Output capture can be forced using an
experimental option.
2015-04-28 17:38:02 -07:00
Pierre-Yves David
1dc90191f8 bundle2: also save output when error happens during part processing
Until this changeset, we were only able to save output if an error happened
during the 'transaction.close()' phase. If the 'processbundle' call raised an
exception, the 'bundleoperation' object was never returned, so the reply bundle
was never accessible and no output could be salvaged. We introduce a quick (but
not very elegant) fix to gain access to any reply created during the processing.

This conclude this output related series. We should hopefully be able client-side to see the
whole server output, in a proper order.

The code is now complex enough that a refactoring of it would make sense on
default.
2015-04-23 16:36:18 +01:00
Pierre-Yves David
1e8ec29191 bundle2: also capture hook output during processing
External hook used to directly write on stdout and stderr. As a result their
output was not captured by the bundle2 processing. This resulted in confusing
out of order output on the client side. We are now capturing hooks output in
this context.
2015-04-23 17:03:58 +01:00
Pierre-Yves David
dcc9ae4956 bundle2: issue remote output as "status" (issue4612)
Remote output should be silenced by --quiet. The issue was found while running
`test-largefiles-cache.t` so it will get tested once we switch bundle2 by
default.
2015-04-24 00:46:48 +01:00
Pierre-Yves David
2d01ad7c2e bundle2: store the salvaged output on the exception object
The re-handling of output is happening in some 'unbundle' callers. We have to
transmit the output information to this place so we stick it on the exception.

This is the third step in our quest for preserving the server output on error
(issue4594). We want to be able to copy the output part from the aborted reply
into the exception bundle.
2015-04-16 03:17:01 -04:00
Pierre-Yves David
9291c81ebf bundle2: add a 'salvageoutput' method on bundle20
This method returns a copy of all 'output' parts added to the bundler.

This is the second step in our quest for preserving the server output on error
(issue4594). We want to be able to copy the output parts from the aborted reply
into the exception bundle.

The function will be used in a later patch.
2015-04-16 03:16:04 -04:00
Pierre-Yves David
ff72f63d50 bundle2: add a 'copy' method on parts
This is the first step in our quest for preserving the server output on error
(issue4594). We want to be able to copy the output parts from the aborted reply
into the exception bundle.

The function will be used in a later patch.
2015-04-16 03:15:28 -04:00
Pierre-Yves David
3c016842a8 bundle2: flush output in a part in all cases
We want to preserve output even when the unbundling fails (eg: hook output). So
we must make sure that everything we have is flushed into the reply bundle.

(This is related to issue4594)
2015-04-11 17:30:45 -04:00
Pierre-Yves David
f105df9465 bundle2: fix names for error part handler
The name is not very important but copy paste banshee got there. We make
distinctive name.
2015-04-11 16:55:14 -04:00
Pierre-Yves David
c24d1f37c9 obsolete: experimental flag to get debug about obsmarkers exchange
The obsolescence markers exchange is still experimental. We (developer) need
more information about what is going on. I'm adding an experimental flag to add
display the amount of data exchanged during bundle2 exchanges.
2015-04-14 11:44:04 -04:00
Pierre-Yves David
af7d20b000 bundle2: rename format, parts and config to final names
It is finally time to freeze the bundle2 format! To do so we:
- rename HG2Y to HG20,
- drop "b2x:" prefix from all part names,
- rename capability to "bundle2-exp" to "bundle2"
- rename the hook flag from 'bundle2-exp' to 'bundle2'
2015-04-09 16:25:48 -04:00
Pierre-Yves David
f96ca2174a unbundle20: allow generic dispatch between unbundlers
We now take full advantage of the 'getunbundler' function by using a
'{version -> unbundler-class}' mapping. This map currently contains a single
entry but will make it easy to support more versions from an extension/the
future.

At some point, this map will probably contain bundler-class information too,
in the same fashion the packer map does. However, this is not critically required
right now so it will happen by itself when needed.

The main target is to allow HG2Y support in an extension to ease transition of
companies using the experimental protocol in production (yeah...) But I've no
doubt this will be useful when playing with a future HG21.
2015-04-06 17:23:11 -07:00
Pierre-Yves David
e57a876dd7 unbundle20: move header parsing into the 'getunbundler' function
The dispatching will be based on the header content, so we need to move this
logic into the factory function.
2015-04-06 16:07:18 -07:00
Pierre-Yves David
9dd801717e unbundle20: retrieve unbundler instances through a factory function
To support multiple bundle2 formats, we will need a function returning
the proper unbundler according to the header. We introduce such aa
function and change the usage in the code base. The function will get
smarter in later changesets.

This is somewhat similar to the dispatching we do for 'HG10' and 'HG11'.

The main target is to allow HG2Y support in an extension to ease transition of
companies using the experimental protocol in production (yeah...) But I've no
doubt this will be useful when playing with a future HG21.
2015-04-06 16:04:33 -07:00
Pierre-Yves David
f5b136bf48 bundle20: move magic string into the class
This makes it easy to create a new bundler class that inherits from
the core one. This matches the way 'changegroup' packers work.

The main target is to allow HG2Y support in an extension to ease transition of
companies using the experimental protocol in production (yeah...) But I've no
doubt this will be useful when playing with a future HG21.
2015-04-06 15:40:12 -07:00
Eric Sumner
7be7f03ddd bundle2.unbundle20: add compressed() method
Bundlerepo uses the compressed() method to determine whether it should write
an uncompressed temporary file.  Since we don't support compressed bundle2 files
at the moment, make this method return true.
2015-02-05 15:56:50 -08:00
Eric Sumner
a5c538fc74 bundle2.unpackermixin: default value for seek() whence parameter
The contract for seek() includes seeking to an offset from the beginning of the
file when whence is omitted; put this implementation in compliance.
2015-02-05 15:52:57 -08:00
Eric Sumner
226e333215 bundle2: seek in part iterator
When iterating over bundle2 parts, add a seek to the iterator so that
processing will continue normally even if the entire part isn't
consumed.
2015-02-05 10:57:45 -08:00
Eric Sumner
bf8078ff25 bundle2: now that we have a seek implementation, use it
Replace bare part.read() calls with part.seek(0, 2) since the return value is
being ignored.  As this doesn't necessarily require building a string that
contains the rest of the part, the potential exists to reduce the memory
footprint of these operations.
2015-02-05 10:56:05 -08:00
Eric Sumner
db734be63f bundle2.unbundlepart: implement seek()
This implements a seek() method for unbundlepart.  This allows on-disk bundle2
parts to behave enough like files for bundlerepo to handle them.  A future
patch will add support for bundlerepo to read the bundle2 files that are
written when the experimental.strip-bundle2-version config option is used.
2015-01-14 16:14:19 -08:00
Eric Sumner
e37a75b13f bundle2.unbundlepart: tell() implementation
Keep track of how many bytes we've returned from read(); fairly straightforward.
2015-01-14 15:57:57 -08:00
Eric Sumner
de1e74f974 bundle2.unbundlepart: keep an index of chunks and their locations
In order to make unbundlepart seekable, we need to keep a record of where the
chunks are so that we can go back to the correct point.
2015-01-14 14:46:23 -08:00
Eric Sumner
37c72c9030 bundle2.unbundlepart: raise payloadchunks from a closure to a method
In a future patch, seek() will need to make a new chunk iterator for
the stream; this places it somewhere it can be called multiple times.
2015-01-14 14:32:22 -08:00
Eric Sumner
26d6ca5b17 bundle2.unpackermixin: control for underlying file descriptor
This patch adds seek(), tell(), and close() implementations for unpackermixin
which forward to the file descriptor's implementation if possible.  A future
patch will use this to make bundle2.unbundlepart seekable, which will in turn
make it usable as a file descriptor for bundlerepo.
2015-01-14 14:24:16 -08:00
Matt Mackall
50094eea66 bundle2: fix parttype enforcement
As spotted by Malte Helmert.
2015-01-17 18:08:47 -08:00
Pierre-Yves David
3256dbc9b3 bundle2: enforce parttype as alphanumerical
The binary format description has always stated that the parttype should be simple,
but it was never really enforced. Recent discussions have convinced me we want to
keep the part type simple and easy to debug. There is enough extensibility in
the rest of the format.
2014-12-18 19:14:01 -08:00