Commit Graph

211 Commits

Author SHA1 Message Date
Eric Sumner
9823f2cb56 bundle2: lowercase part types
Since the capitalization no longer carries any meaning (previous diff), this
patch normalizes all of the bundle2 part type strings to lower case.
2014-12-17 15:11:26 -08:00
Mads Kiilerich
b420dd92b1 spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
Eric Sumner
973f0c3522 bundle2-push: provide transaction to reply unbundler
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.

This diff adds an experimental config option "bundle2.pushback" which provides
a transaction to the reply unbundler during a push operation.  This behavior is
opt-in because of potential security issues: the response can contain any part
type that has a handler defined, allowing the server to make arbitrary changes
to the local repository.
2014-11-21 15:50:38 -08:00
Eric Sumner
bd16762201 push: elevate phase transaction to cover entire operation
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.

Most pushes already open a transaction in order to sync phase information.
This diff replaces that transaction with one that spans the entire push
operation.

This transaction will be used in a later patch to guard repository changes
made during the reply handler.
2014-11-21 15:06:38 -08:00
Eric Sumner
f1a430fbce pull: extract transaction logic into separate object
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.

Aside from the transaction logic, the pulloperation class is used primarily as
a logic-free data structure for storing state information.  This diff extracts
the transaction logic into its own class that can be shared with push
operations.
2014-11-21 14:32:57 -08:00
Matt Mackall
174e7f793d merge with stable 2014-11-22 17:09:04 -06:00
Pierre-Yves David
e6c651e56b push: stop independent usage of bundle2 in syncphase (issue4454)
The phase-syncing code was using bundle2 if the remote supported it. It was
doing so without regard to bundle2 activation on the client. Moreover, the
phase push is now properly included in the unified bundle2 push, so having extra
code in syncphase should be useless. If the remote is bundle2-enabled, the
phases should already be synced.

The buggy verification code was leading to a crash when a 3.2 client was pushing
to a 3.1 server. The real bundle2 path detected that their versions were
incompatible, but the syncphase code failed to, sending an incompatible bundle2
to the server.

We drop the useless and buggy code as a result. The "else" clause is
de-indented in the process.
2014-11-19 01:36:17 +00:00
Pierre-Yves David
8259127ccb transaction: pass the transaction to 'postclose' callback
This mirrors the API for 'pending' and 'finalize' callbacks. I do not have
immediate usage planned for it, but I'm sure some callback will be happy to
access transaction related data.
2014-11-08 16:35:15 +00:00
Pierre-Yves David
4cc6125cd7 exchange: use the postclose API on transaction
As with changegroup, we should wait for the transaction to be really closed
before scheduling hook execution.
2014-10-28 14:58:36 +01:00
Mike Edgar
a86ac22655 exchange: swap "push" for "pull" in pulloperation docstring 2014-10-24 15:58:46 -04:00
Mike Edgar
2dc006a3bd exchange: prepare kwargs for bundle2 part generation exactly once 2014-10-29 12:46:08 -04:00
Mike Edgar
dd8ab953f0 exchange: fix indentation in _pullchangeset 2014-10-25 00:40:51 -04:00
Pierre-Yves David
70f41de9c6 bundle2: handle empty 'b2x:changegroup' value in push and pull
Changeset d79feb65f3ee added advertising of supported changegroup version
through the new 'b2x:changegroup' capability. However, this capability is not
new and has been around since 3.1 with an empty value. This makes new clients
unable to push to 3.2 servers through bundle2 as they cannot find a common
changegroup version to use from and empty list.

Treating empty 'b2x:changegroup' value as old client fixes it.
2014-11-06 09:52:57 +00:00
Pierre-Yves David
d6b8860637 changelog: handle writepending in the transaction
The 'delayupdate' method now takes a transaction object and registers its
'_writepending' method for execution in 'transaction.writepending()'. The hook can then
use 'transaction.writepending()' directly.

At some point this will allow the addition of other file creation
during writepending.
2014-10-17 21:55:31 -07:00
Pierre-Yves David
660a827d16 push: send highest changegroup format supported by both side
When using bundle2, we find the common subset of supported changegroup-packers
and we pick the max of them. This allow to use generaldelta aware changegroups through
bundle2.
2014-10-17 12:19:24 -07:00
Pierre-Yves David
f6830ffac2 getbundle: send highest changegroup format supported by both side
When using bundle2, we find the common subset of supported changegroup-packers
and we pick the max of them. This allow to use generaldelta aware changegroup
through bundle2.
2014-10-17 14:59:10 +02:00
Sune Foldager
e8de499479 changegroup: introduce "raw" versions of some commands
The commands getchangegroup, getlocalchangegroup and getsubset now each
have a version ending in -raw. The raw versions return the chunk generator
from the changegroup packer directly, without wrapping it in a chunkbuffer
and unpacker. This avoids extra chunkbuffers in the bundle2 code path.

Also, the raw versions can be extended to support alternative packers
in the future, to be used from bundle2.
2014-10-17 14:41:02 +02:00
Mads Kiilerich
523c87c1fe spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
Gregory Szorc
d0818afbd4 exchange: don't report failure from identical bookmarks
48062b2d0f30 regressed the behavior of pushing an unchanged bookmark to
a remote. Before that commit, pushing a unchanged bookmark would result
in "exporting bookmark @" being printed. After that commit, we now see
an incorrect message "bookmark %s does not exist on the local or remote
repository!"

This patch fixes the regression introduced by 48062b2d0f30 by having
the bookmark error reporting code filter identical bookmarks and adds
a test for the behavior.
2014-10-24 17:24:46 -05:00
Gregory Szorc
ae20b321ce bookmarks: explicitly track identical bookmarks
bookmarks.compare() previously lumped identical bookmarks in the
"invalid" bucket. This patch adds a "same" bucket.

An 8-tuple for holding this state is pretty gnarly. The return value
should probably be converted into a class to increase readability. But
that is beyond the scope of a patch intended to be a late arrival to
stable.
2014-10-24 10:40:37 -07:00
Pierre-Yves David
b3b7700935 hook: schedule run "b2x-transactionclose" for after lock release
Hooks that run after the transaction need to be able to touch the
repository. So we need to run them after the lock release. This is
similar to what the "changegroup" hook is doing in the
`addchangegroup` function.
2014-10-17 02:17:36 -07:00
Mike Hommey
541e928ae7 bundle2: remove _getbundleextrapart
Extensions can now add new part generators with the getbundle2partsgenerator
decorator instead.
2014-09-25 11:53:28 +09:00
Pierre-Yves David
15397993b6 bundle2: change header size and make them signed (new format)
We are changing all integers that denote the size of a chunk to read to int32.
There are two main motivations for that.

First, we change everything to the same width (32 bits) to make it possible for
a reasonably agnostic actor to forward a bundle2 without any extra processing.
With this change, this could be achieved by just reading int32s and forwarding
chunks of the size read. A bit a smartness would be logic to detect the end of
stream but nothing too complicated.

Second, we need some capacity to transmit special information during the bundle
processing. For example we would like to be able to raise an exception while a
part is being read if this exception happend while this part was generated.
Having signed integer let us use negative numbers to trigger special events
during the parsing of the bundle.

The format is renamed for B2X to B2Y because this breaks binary
compatibility. The B2X format support is dropped. It was experimental to
allow this kind of things. All elements not directly related to the binary
format remain flagged "b2x" because they are still compatible.
2014-10-01 23:40:23 -05:00
Pierre-Yves David
2c1a6817be pull: call the b2x-transactionclose hook when closing the transaction
We need a wider set of hooks to process all the changes that happened during the
pull transaction. We reuse the experimental `b2x-transactionclose` hook set
from server's unbundle for consistency. This hook is experimental and will not
remains as-is forever, but this will open the door for experimentation in 3.2.
2014-10-15 04:19:37 -07:00
Pierre-Yves David
830b7b0082 pull: add source information to the transaction
The source information can, should be applied once when opening the transaction
for the pull. This will lets element processed within a bundle2 be aware of them
and open the door to running a set of hooks when closing this pull transaction.

This is similar to what is done in server's unbundle call.
2014-10-14 01:40:04 -07:00
Pierre-Yves David
03cb1a74e8 changegroup: store source and url in the hookargs dict
We store the source and url of the current data into `transaction.hookargs` this
let us inherit it from upper layers that may have created a much wider
transaction. We have to modify bundle2 at the same time to register the source
and url in the transaction. We have to do it in the same patch otherwise, the
`addchangegroup` call would fill these values and the hook calling will crash
because of the duplicated 'source' and 'url' arguments passed to the hook call.
2014-10-14 00:06:46 -07:00
Mike Hommey
9962a81363 bundle2: merge return values when bundle contains multiple changegroups
A bundle2 may contain multiple parts adding changegroups, in which case there
are multiple operation records for changegroups, each with its own return
value. Those multiple return values are aggregated in a single cgresult value
for the whole operation.

As can be seen in the associated test case, the situation with hooks is not
really the best, but without deeper thoughts and changes, we can't do much
better. Hopefully, things will be improved before bundle2 is enabled by default.
In the meanwhile, multiple changegroups is not expected to be in widespread
use, and even less expected to be used for pushes. Also, not many clients
cloning or pulling bundle2 with multiple changesets are not expected to have
changegroup hooks anyways.
2014-10-16 16:03:04 +09:00
Durham Goode
bbb89aae08 obsolete: add exchange option
This adds an option that enables obsolete marker exchange.
2014-10-14 13:26:01 -07:00
Pierre-Yves David
7e076db46b pull: use stepsdone instead of todosteps
The push process uses a `stepsdone` attribute instead of a `todosteps` one (with
the logic swapped). We unify the two process by picking the `stepsdone` version.
I feel like `stepsdone` better fits extensions that would want to extend the push
exchange process.
2014-10-12 06:40:36 -07:00
Pierre-Yves David
b60194b959 pull: make discovery phase extensible
We apply the same approach as for push and make the discovery extensible. There
is only one user in core right now, but we already know we'll need something
smarter for obsmarkers. In fact the evolve extension could use this to cleanly
extend discovery.

The main motivation for this change is consistency between push and pull.
2014-09-27 00:29:06 -07:00
Pierre-Yves David
b81d873dad exchange: have pull return the pulloperation object
We mimic what was done for `push` for similar reason. We are about to drop
`localrepo.pull` (for consistency with dropping `localrepo.push` and we better
have an API as extensible as `push` is.

Find explanations about localrepo.push removal in 88d9d4ec499e.
2014-10-03 11:07:47 -05:00
Pierre-Yves David
6638ea8bec pull: perform bookmark updates in the transaction 2014-09-28 15:21:38 -07:00
Pierre-Yves David
3cfceb8bab pull: gather explicit bookmark pulls with bookmark updates
There is no reason to make them at different times. So we gather them. This is
the first step toward merging them.
2014-09-28 13:43:31 -07:00
Pierre-Yves David
610acb031e pull: retrieve bookmarks through bundle2
We can retrieve any pushkey namespace through bundle2. So we also ask for
bookmark data and use them to update the local repo.
2014-09-27 01:59:56 -07:00
Pierre-Yves David
d09b1b6f90 pull: retrieve bookmarks before obsmarkers
Retrieving bookmarks before obsmarkers will avoid turning some changesets hidden
right before making them visible again if a bookmark keeps them visible.
2014-09-27 01:37:56 -07:00
Pierre-Yves David
81f4fc06a6 pull: move bookmark pulling into its own function
This requires adding an attribute on the pulloperation object. The bookmark
pulling is protected behind a "todostep" as other steps of pull.
2014-09-27 01:31:15 -07:00
Pierre-Yves David
0a11dabe30 pull: perform the todostep inside functions handling old way of pulling
This matches what is done during push.
2014-09-27 01:34:02 -07:00
Pierre-Yves David
f69b4810ae push: gather all bookmark decisions together
The discovery phases for bookmarks now use the list of explicitly pushed bookmarks
to do addition, removal and overwriting.

Tests are impacted because this reduces the amount of listkeys calls issued, removes
some duplicated messages and improves the accuracy of some messages.
2014-09-27 20:51:53 -07:00
Pierre-Yves David
198e8354e8 push: prepare the issue of multiple kinds of messages
To gather all the bookmark pushing actions together, we need code performing
those actions to be ready for them. We need to be able to produce different
messages for different actions.
2014-09-26 18:33:11 -07:00
Pierre-Yves David
61fb24aaa1 push: set bkresult when pushing bookmarks through bundle2 2014-10-02 13:19:49 -05:00
Pierre-Yves David
627b3886af pull: move bookmark movements inside the exchange.pull
There is no reason for bookmarks to get a special treatment. As a first step we
move the code as is in the `exchange.pull` function. Integration with the rest
of the flow will come later.

Adding bookmarks to pull means that most clone paths are now pulling bookmarks
through pull. We ensure that bookmark-update messages are properly suppressed in
that case.

In test-pull-http.t the 'requesting all changes' message disappear because we
now get the authentication error on the `listkeys`command before such message
is printed.
2014-09-26 17:44:00 -07:00
Matt Mackall
8956f42fc4 exchange: remove a broken i18n abuse 2014-10-02 11:35:20 -05:00
Pierre-Yves David
4af2b1bb81 push: perform bookmark export in the push function
This part is responsible for adding new bookmarks on the remote.  Before that,
it was done on its own in `commands.push`. The export is still not integrated
with the rest of the push process, but at least it now dwells in the right
function.
2014-09-25 02:53:29 -07:00
Pierre-Yves David
9695890ed2 push: add pushoperation.bkresult
This attribute will be used to carry the result of the bookmark push (when the
`push` function will effectively be doing any bookmarks pushes)
2014-09-25 00:57:36 -07:00
Pierre-Yves David
90372104e5 push: pass list of bookmark to exchange.push
Currently stored but not unused. This parameter will control bookmarks explicitly
pushed (added to the server if missing).
2014-09-25 01:49:20 -07:00
Pierre-Yves David
97a4fbb3c9 exchange: import bookmarks as bookmod
Using the original names makes it difficult to use `bookmarks` as a variable
name.
2014-09-25 15:26:09 -07:00
Pierre-Yves David
d166108f19 push: exchange.push now returns the pushoperation object
Returning the pushop object gives access to more information (upcoming bookmark
push result for example). `localrepo.push` currently extracts the `cgresult` for
callers.
2014-09-25 02:21:59 -07:00
Pierre-Yves David
1c91d9eb8c push: rename pushop.ret to pushop.cgresult
We are about to introduce more results-related attributes on pushop (for
bookmarks) so we need a more distinctive name. We now use `cgresult` as
`pulloperation` does.
2014-09-25 00:55:39 -07:00
Mike Hommey
518979521d bundle2: remove heads and common arguments to getbundle parts generators 2014-09-24 21:50:03 -07:00
Mike Hommey
4f54b8d62e bundle2: separate bundle10 and bundle2 cases in getbundle()
The primary goal is to make it easier for extensions to alter how bundle2
parts are laid out. They now can use the getbundle2partsgenerator decorator
to add new parts, or directly act on getbundle2partsmapping to wrap existing
part functions.

Note the 'request for bundle10 must include changegroup' error was kept
under the same conditions as before, although the logic changes don't make
it obvious.
2014-09-25 11:47:57 +09:00