Commit Graph

60 Commits

Author SHA1 Message Date
Augie Fackler
cb268cbd2f merge with stable 2016-08-15 12:26:02 -04:00
Augie Fackler
97b8f423b9 exchange: correctly specify url to unbundle (issue5145)
This parameter is slightly confusingly named in wireproto, so it got
mis-specified from the start as 'push' instead of the URL to which we
are pushing. Sigh. I've got a patch for that which I'll mail
separately since it's not really appropriate for stable.

Fixes a regression in bundle2 from bundle1.
2016-08-05 16:25:15 -04:00
Pierre-Yves David
1ba19266a7 tests: use 'legacy.exchange' option in 'test-bundle2-exchange.t'
The new option will stay around. The experimental option was only meant to be
temporary.
2016-08-02 15:23:03 +02:00
Pierre-Yves David
a7ac53500f tests: remove initial bundle2 enabling in various bundle2 tests
Bundle 2 is enable by default since 3.6 so we don't need this anymore.

The remaining use of 'experimental.bundle2-exp' are there to test legacy behavior
with bundle 1. Future patches will introduce a way outside of experimental to
test that.
2016-08-02 14:54:06 +02:00
Jun Wu
463f2aebe1 tests: reorder hg serve commands
chg currently does not support hg serve -d. It has a quick path testing if the
command is hg serve -d and fallbacks to hg if so. But the test only works if
"serve" is the first argument since the test wants to avoid false positives
(for example, "-r serve" is different).
This patch reorders "hg server" commands in tests, making them chg friendly.
2016-03-15 09:51:54 +00:00
Mateusz Kwapich
6688b1c845 hooks: add HG_NODE_LAST to txnclose and changegroup hook environments
Sometimes a txnclose or changegroup hook wants to iterate through all
the changesets in transaction: in that situation usually the revset
`$HG_NODE:` is used to select the revisions. Unfortunately this revset
sometimes may contain too many changesets because we don't have the
write lock while the hook runs newer changes may be added to
repository in the meantime.

That's why there is a need for extra variable carrying the information about
the last change in the transaction.
2016-01-05 17:37:59 -08:00
Gregory Szorc
b5e53cc1d6 wireproto: support disabling bundle1 only if repo is generaldelta
I recently implemented the server.bundle1* options to control whether
bundle1 exchange is allowed.

After thinking about Mozilla's strategy for handling generaldelta
rollout a bit more, I think server operators need an additional
lever: disable bundle1 if and only if the repo is generaldelta.

bundle1 exchange for non-generaldelta repos will not have the potential
for CPU explosion that generaldelta repos do. Therefore, it makes sense
for server operators to continue to allow bundle1 exchange for
non-generaldelta repos without having to set a per-repo hgrc option
to change the policy depending on whether the repo is generaldelta.

This patch introduces a new set of options to control bundle1 behavior
for generaldelta repos. These options enable server operators to limit
bundle1 restrictions to the class of repos that can be performance
issues. It also allows server operators to tie bundle1 access to store
format. In many server environments (including Mozilla's), legacy repos
will not be generaldelta and new repos will or might be. New repos often
aren't bound by legacy access requirements, so setting a global policy
that disallows access to new/generaldelta repos via bundle1 could be a
reasonable policy in many server environments. This patch makes this
policy very easy to implement (modify global hgrc, add options to
existing generaldelta repos to grandfather them in).
2015-12-20 11:56:24 -08:00
Gregory Szorc
9af952ad6e wireproto: config options to disable bundle1
bundle2 is the new and preferred wire protocol format. For various
reasons, server operators may wish to force clients to use it.

One reason is performance. If a repository is stored in generaldelta,
the server must recompute deltas in order to produce the bundle1
changegroup. This can be extremely expensive. For mozilla-central,
bundle generation typically takes a few minutes. However, generating
a non-gd bundle from a generaldelta encoded mozilla-central requires
over 30 minutes of CPU! If a large repository like mozilla-central
were encoded in generaldelta and non-gd clients connected, they could
easily flood a server by cloning.

This patch gives server operators config knobs to control whether
bundle1 is allowed for push and pull operations. The default is to
support legacy bundle1 clients, making this patch backwards compatible.
2015-12-04 15:12:11 -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
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
ceec7b0056 bundle2: allow lazily acquiring the lock
In the external pushrebase extension, it is valuable to be able to do some work
without taking the lock (like running expensive hooks). This enables
significantly higher commit throughput.

This patch adds an option to lazily acquire the lock. It means that all bundle2
part handlers that require writing to the repo must first call
op.gettransction(), when in this mode.
2015-10-05 16:19:54 -07:00
Pierre-Yves David
5e9a275007 bookmarks: change bookmark within a transaction
For some time, bookmark can and should be moved in the transaction. This
changeset migrates the 'hg bookmarks' commands to use a transaction.

Tests regarding rollback and transaction hooks are impacted for
obvious reasons. Some have to be slightly updated to keep testing the
same things. Some can just be dropped because they do not make sense
anymore.
2014-09-28 00:49:36 -07:00
Matt Harbison
de473412b1 tests: restore 'python' and '$TESTDIR/' for dummyssh invocation
This is a backout of 93589179c542, and a partial backout of 9b1628b91e74.

Windows won't execute 'dummyssh' directly, presumably because CreateProcess()
doesn't know how to execute a bash script:

   $ hg clone -e "dummyssh" ssh://user@dummy/cloned sshclone
   remote: 'dummyssh' is not recognized as an internal or external command,
   remote: operable program or batch file.
   abort: no suitable response from remote hg!
   [255]

With the restoration of python as the executable, $TESTDIR needs to be restored
for these invocations, because python won't search $PATH for 'dummyssh':

   $ hg clone -e "python dummyssh" ssh://user@dummy/cloned sshclone
   remote: python: can't open file 'dummyssh': [Errno 2] No such file or directory
   abort: no suitable response from remote hg!
   [255]
2015-06-09 21:39:33 -04: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
97353a98b6 push: catch and process PushkeyFailed error
We add a way to register "pushkey failure callback" that will be used if the
push is aborted by a pushkey failure. A part generator adding mandatory pushkey
parts should register a failure callback for all of them. The callback will be
in charge of generating a meaningful abort if this part fails.

If no callback is registered, the error is propagated.

Catch PushkeyFailed error in exchange.
2015-06-05 16:30:11 -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
Matt Mackall
36e5db11e5 tests: simplify printenv calls
Make printenv executable so that we don't need python, TESTDIR, or
quoting.
2015-06-08 15:10:15 -05:00
Matt Mackall
c64d336faa tests: simplify calls to dummyssh
dummyssh is marked executable and is in the path, no need for python,
TESTDIR, or quotes.
2015-06-08 15:02:49 -05:00
Matt Mackall
b709208c37 tests: drop DAEMON_PIDS from killdaemons calls 2015-06-08 14:55:40 -05:00
Matt Mackall
3ad28905f6 tests: drop explicit $TESTDIR from executables
$TESTDIR is added to the path, so this is superfluous. Also,
inconsistent use of quotes means we might have broken on tests with
paths containing spaces.
2015-06-08 14:44:30 -05:00
Pierre-Yves David
cfe00fb313 ssh: capture output with bundle2 again (issue4642)
I just discovered that we are not displaying ssh server output in real time
anymore. So we can just fall back to the bundle2 output capture for now. This
fix the race condition issue we where seeing in tests. Re-instating real time
output for ssh would fix the issue too but lets get the test to pass first.
2015-05-18 22:35:27 -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
Matt Harbison
a3c34e558c test-bundle2-exchange: make hooks compatible with Windows
The cmd.exe process doesn't fail the hook when "; false" is appended, and its
echo command prints out the quote characters.
2015-04-26 15:10:09 -04: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
ae773fc61e bundle2: capture output issue during transaction close
We were capturing all output issue during bundle2 processing, and all output
issue during transaction rollback in case of failure. However, the output issue
during transaction commit was still roaming the land freely. It is now put back
in line.

This let the user see output from 'pretxnclose' and 'txnclose' (and related) in
the right order.
2015-04-23 14:54:45 +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
47985fc815 bundle2: capture transaction rollback message output (issue4614)
The output from the transaction rollback was not included into the reply bundle.
It was eventually caught by the usual 'unbundle' output capture and sent to the
client but the result was out of order on the client side. We now capture the
output for the transaction release and transmit it the same way as all other
output.

We should probably rethink the whole output capture things but this would not be
appropriate for stable.

The is still multiple cases were output failed to be properly capture, they will
be fixed in later changesets.
2015-04-23 14:20:36 +01:00
Pierre-Yves David
bf28a4a61f changelog: fix readpending if no pending data exist (issue4609)
Since transaction are used for more than just changesets, it is possible
to have a transaction without new changesets at all. In this case no
''00changelog.i.a' are written. In all cases the 'changelog.readpending'
method is called if the repository has any pending data. The 'revlog' logic
provides empty content if the file is missing, so the whole operation
resulted in an empty changelog.

We now skip reading the pending file if it is missing.
2015-04-20 17:16:22 +02:00
Pierre-Yves David
fe42feb68e bundle2-localpeer: properly propagate the server output on error (issue4594)
In case of errors, output parts salvaged from the reply bundle need to be
processed for outputting their content. This concludes our quest for fixing
issue4594.
2015-04-16 04:01:51 -04:00
Pierre-Yves David
0bbcf25859 bundle2-wireproto: properly propagate the server output on error (issue4594)
In case of errors, output parts salvaged from the reply bundle are re-injected
into the bundle carrying the exception.

We still need to fix the situation for non-wireprotocol push.
2015-04-16 03:17:37 -04:00
Pierre-Yves David
b13ab55f2f unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596)
A bundle2 may contain bookmark updates (or other extension content) that
requires the 'wlock' to be written. As 'wlock' must be acquired before 'lock',
we must stay on the side of caution and use both in all case to ensure their
ordering.
2015-04-15 01:16:40 -04:00
Pierre-Yves David
93e144e4f3 run-test: enable the devel warning during tests
This should help us to catch new locking order issues as soon as possible.

There are two harmless test updates (from the config change). Moreover, some
bundle2 tests are displaying warning for a legitimate reason. The use of pushkey
during the unbundle process may requires the 'wlock' after 'lock' (around the
whole unbundle process was taken). This is non-trivial to fix, so I better have
the check on, with the warning in the test than the check off. See issue4596 for
details.
2015-04-12 09:46:03 -04:00
Pierre-Yves David
502fe91f02 transaction: introduce a transaction ID, to be available to all hooks
The transaction ID is built from the object ID and creation time stamp to make
sure it is unique.
2015-04-15 11:11:54 -04:00
Pierre-Yves David
d9bafadc4d bundle2: use unbundle source as transaction name
This is what a bundle 1 push is doing. This got caught by trying to run the
whole test-suite using bundle2 for exchanges.
2015-04-11 13:58:36 -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
048d1e69ee bundle2: test hooking using the new transaction-level hook
There is no strong reason to keep a bundle2-level hook as we can use the
transaction-level hook.
2015-03-11 17:53:50 -07:00
Martin von Zweigbergk
f2bc0a75a2 test-bundle2-exchange: create temp script in $TESTTMP, not $TESTDIR
The bundle2-pushkey-hook.sh script is currently created in $TESTTMP,
and leaves an untracked file in that directory (tests/) after running.
2015-01-07 14:30:40 -08:00
Matt Harbison
8e87aedc01 tests: make a multi-statement hook in bundle2-exchange Windows compatible
This is similar to the fix in ab91e34fea50.
2014-12-24 12:07:59 -05:00
Pierre-Yves David
fe9585a642 pushkey: run hook after the lock release
The pushkey operation used to be in its own wireprotocol command and (in
practice) always be lock free when running the hook. With bundle2, it happen in
a greater scheme and a hook running locking command would get stuck. We now run
such hooks after the lock release as similar hook do.

Bundle2 test are altered to ensure we are lockfree at hook running time.
2014-12-22 15:48:39 -08:00
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
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
Matt Harbison
b2eb2ec474 tests: fix another multi-statement hook for Windows
The double quotes are necessary, otherwise it tries to pipe into a program named
'short'.  An '&' could serve as a command separator on Windows instead of ';',
but I don't see any obvious way to swap these depending on the platform.  In
this case though, there really wasn't a need for multiple statements.
2014-11-20 20:07:34 -05:00
Pierre-Yves David
160c394fe7 phases: read pending data when appropriate
If we are called by a hook and pending data exists, read those.
2014-10-17 22:23:06 -07:00
Pierre-Yves David
4012eb31b0 bookmark: read pending data when appropriate
If we are called by a hook and pending data exists, read it.
2014-09-28 21:27:48 -07:00
Pierre-Yves David
0e44aeb8c0 test-bundle2: check visible data in pre/post-transaction hooks
We are about to make bookmarks and phases available for hooks.
Therefore we need a witness for this new availability. We introduce
the new hooks in a distinct changeset to reduce the noise in the ones
with actual changes.
2014-11-12 16:54:57 +00:00
Pierre-Yves David
3ace7493d7 transaction: write pending generated files
Such file are generated with a .pending prefix. It is up to the reader to
implement the necessary logic for reading pending files.

We add a test to ensure pending files are properly cleaned-up in both success and
error cases.
2014-10-17 22:19:05 -07: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
Pierre-Yves David
130c63f6e2 changegroup: use the 'postclose' API on transaction
The post-transaction hooks run after the lock release (because hooks may want to
touch the repository), but they must only run if the transaction is successfully
closed.

We use the new 'addpostclose' method on transaction to register a callback
installing this post-lock-release call.
2014-10-28 15:44:23 +01: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
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