Commit Graph

182 Commits

Author SHA1 Message Date
Stanislau Hlebik
1b98921c48 infinitepush: add function _savebookmarks()
Summary: It will be used in a few places (see next diff in stack)

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4001105

Tasks: 12479677

Signature: t1:4001105:1476330730:0ba513a3bab131b8eadadd4e90576880663f0d49
2016-10-13 00:12:24 -07:00
Stanislau Hlebik
edf67f905d infinitepush: use addbookmarkandbundle
Summary:
Let's use a function that saves bookmarks, nodes and bundle
in the same time. For fileindexapi this call is equivalent
to addbundle() and addbookmarks() call. For sqlindexapi this
call makes two calls in one transaction.

Test Plan:
1) Run `test-infinitepush-bundlestore.t`
2) Test sql index locally

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4001243

Tasks: 12479677

Signature: t1:4001243:1476227921:9d449b743686762edce4c07d95266ef7ae69c2b5
2016-10-12 02:59:23 -07:00
Stanislau Hlebik
87084f5d59 infinitepush: add check for db connectness
Summary: This check was missing before

Test Plan: It's difficult to test and the change should be safe

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4001229

Tasks: 12479677

Signature: t1:4001229:1476227703:9e40d6efa9892e1e0d7fbcb24fdce3d607a3a7fe
2016-10-12 02:59:07 -07:00
Stanislau Hlebik
a4b6a2a1bb infinitepush: better error message
Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4001218

Tasks: 12479677

Signature: t1:4001218:1476227692:c60b3def4e82911a40fe577bc44cf7d24cba9438
2016-10-12 02:57:53 -07:00
Stanislau Hlebik
f1e2014203 infinitepush: add option to force non-fast-forward push
Summary:
Non-fast-forward pushes were disallowed. But having a
mutable shared history for scratch branches is a very
nice feature. Let's use --force option to force
non-fast forward push.

Test Plan: Run test-infinitepush-bundlestore.t

Reviewers: durham, rmcelroy, mitrandir

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3994813

Tasks: 12479677
2016-10-10 03:48:21 -07:00
Stanislau Hlebik
d63ba71acf infinitepush: remove defaults
Summary: I think it's better throw if misconfigured then silently proceed

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: durham, mitrandir, quark, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3967202

Tasks: 12479677

Signature: t1:3967202:1475581664:9d7b3e21fce48a49eda35bde473915cb64dfdfa0
2016-10-04 04:52:31 -07:00
Stanislau Hlebik
e42fe1fdc5 infinitepush: do not require mysql.connector to be present on client
Summary:
Previously error was thrown if mysql.connector wasn't present on client hosts.
But there is no need for mysql.connector to be installed on clients.
Remove global imports to fix it and create bundlestore() only for server repo.

P. S.
Changes in test is required because bundlestore() is not created if
infinitepush.server=True is not present in config.

Test Plan:
Uninstall mysql.connector: `sudo yum remove mysql-connector-python`
Enable infinitepush extension in any repo and run any hg command (hg st,
for example). Make sure it doesn't throw exceptions.

Install mysql.connector: `sudo yum install mysql-connector-python`.
Run `test-infinitepush-bundlestore.t`

Reviewers: durham, mitrandir, quark, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3967189

Tasks: 12479677

Signature: t1:3967189:1475581802:fbaafceac298242d0a449267ec0d68e290c3f262
2016-10-04 04:52:03 -07:00
Stanislau Hlebik
ddd4873227 infinitepush: temp remotenames fix
Summary:
Hack to fix interaction with remotenames. Remotenames push '--to' bookmark to the server but we don't want to push scratch bookmark to the server. Let's delete '--to' and '--create' and also set allow_anon to True (because if --to is not set remotenames will think that we are pushing anonymoush head).


Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: durham, mitrandir, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3937202

Tasks: 12479677

Signature: t1:3937202:1475170335:fa4d39e1e17bea67b62b99dfc4cd2ffa4e5d6bea
2016-10-02 05:13:06 -07:00
Stanislau Hlebik
387f18b269 infinitepush: fix push of scratch bookmark on existing commit
Summary:
It's possible to push new scratch bookmark which points to existing scratch
commit. Previously it has failed with a stack trace.

Unfortunately it still doesn't allow to push scratch bookmark that points
to non-scratch commit. It requires more complex changes so
it will be fixed later if necessary.

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3936728

Tasks: 12479677

Signature: t1:3936728:1475078059:ac4588e086b0344070a90f806b6f518c6e187c3b
2016-10-02 03:05:50 -07:00
Stanislau Hlebik
7f75c82f54 infinitepush: fix mysql indexapi
Summary:
Bookmark can be moved to another node and node can be moved to another bundle.
In this case INSERT will fail because of the PRIMARY KEY violation.
Let's add ON DUPLICATE KEY UPDATE which will update existing row instead of
creating a new one.

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3936281

Tasks: 12479677

Signature: t1:3936281:1475078339:d2ff0a01e1d753570c60172c5ef34ceeb7af1b96
2016-10-02 02:55:36 -07:00
Stanislau Hlebik
ba3ebe099e infinitepush: fix interaction with pushrebase
Summary:
infinitepush bundle2 part should be run before pushrebase bundle2 part. This is a bit tricky since both pushrebase and infinitepush change the `extensions._order` and both of them try to load before bundle2 `changeset` part.

I suggest to load before 'changeset' or pushrebase part whichever is earlier. Then we have two situations:
1) pushrebase comes first. It sets it's part before 'changeset' part, then infinitepush sets it's part before pushrebase part.
2) infinitepush comes first. It sets part before 'changeset' and pushrebase part, then pushrebase sets it's part before 'changeset' part. Since infinitepush part comes before 'changeset' part it still be before pushrebase part.

This solution is not robust but it should be fine for now. The proper solution requires changes upstream that will introduce dependencies between bundle2 parts.

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3930697

Tasks: 12479677

Signature: t1:3930697:1475079064:1b5851df4d2067ec21ec01e7510ddf83ff1684ad
2016-10-02 02:54:03 -07:00
Stanislau Hlebik
24be1a2da5 infinitepush: add bundle-store option to push
Summary:
--bundle-store option makes push go to bundle store
even if bookmark is not specified or bookmark doesn't match scratch branch pattern.
The main reason for the `--bundle-store` is to be able to push not a scratch bookmark, but a scratch commit, for example, `hg push -r . --bundle-store`.
It will be useful when we will save all the local commits in the bundlestore.

To do this:
1) Wrap `discovery.checkheads()` to allow push to scratch branch even if new head is created.
2) Make scratchbranchpat params advisory because now bookmark may not be specified.

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: mitrandir, rmcelroy, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3862665

Tasks: 12479677

Signature: t1:3862665:1475077612:7e02a5bdc1da28161e45029b1e3a38fe8223a305
2016-09-28 13:17:25 -07:00
Stanislau Hlebik
21b475a2f0 infinitepush: lint fixes
Summary:
Remove generic exception.
Remove trailing whitespace.
Remove unused import

#accept2ship

Test Plan: Run `test-check-code-hg.t` and `test-infinitepush-bundlestore.t`

Reviewers: #sourcecontrol, ttung, jeroenv

Reviewed By: jeroenv

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3876225

Signature: t1:3876225:1474015261:adff2496c4e36f19e3315856f1a0102eb7e9dc7e
2016-09-16 01:45:33 -07:00
Stanislau Hlebik
23ab46339b infinitepush: use configscratchpush setconfig param
Summary:
We are going to add `push` option to force commits to go to bundle store.
This is a preliminary refactoring. Add another experimental config param that sets whether this is a scratch or usual push

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: durham, rmcelroy, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3862604

Tasks: 12479677

Signature: t1:3862604:1473934819:3ead319a885d99dd9a215941b317540121739b32
2016-09-15 03:36:24 -07:00
Stanislau Hlebik
e55b2350c3 infinitepush: rename + lint fix
Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: durham, rmcelroy, mitrandir

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3856484

Tasks: 12479677
2016-09-14 00:59:43 -07:00
Stanislau Hlebik
754b5a4518 infinitepush: allow pulling one scratch and many non-scratch boomarks at the same time
Summary:
There is no point in disallowing it.
The next step is to allow to fetch arbitrary many scratch bookmarks with one command.

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: durham, rmcelroy, mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3835502

Tasks: 12479677
2016-09-13 02:34:55 -07:00
Stanislau Hlebik
936dff7c8b infinitepush: record scratch bookmark changes after the pull
Summary:
scratchbookmarks are not automatically pulled (because they are not showed in
listkeys). Let's record them after the actual pull. It introduces a race
condition. But this race condition is unlikely and shouldn't be harmful.

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: mjpieters, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3835414

Tasks: 12479677

Signature: t1:3835414:1473703998:554c890be50f732f34b2793160ee1abb26561e39
2016-09-13 02:34:55 -07:00
Stanislau Hlebik
fc7a658d2f infinitepush: use listkeyspatterns method
Summary:
Diff introduces `listkeyspatterns` wireproto method. In future it will be able to filter keys by pattern, but for now it has limited functionality:
 1) it is able to find scratch bookmarks only by it's full name (no patterns)
 2) and it doesn't filters non-scratch bookmarks.

Test Plan: Run `test-infinitepush-bundlestore.t`

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3797800

Tasks: 12479677

Signature: t1:3797800:1473440073:61db6803235c53afbb3cdc72084aa35ce7d0ee63
2016-09-12 02:41:22 -07:00
Stanislau Hlebik
39fa21c146 infinitepush: sqlindex
Summary:
Infinitepush index implementation that uses mysql db to store data.

Three tables:
1) Node to bundle
2) Bookmark to node
3) All bundles (this is necessary to
 find unused bundles.

Test Plan: Code was tested but tests are not included in the diff - see comments below

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3811247

Tasks: 12479677

Signature: t1:3811247:1473378520:bc23b3436aa2e618a7bfefd2d571257dfe8ace94
2016-09-09 09:16:43 -07:00
Stanislau Hlebik
26d5eff9de infinitepush: external bundle store
Summary:
Use external bundles to store bundles.
Put and get binaries should be provided to upload/download bundles to/from external store (see `put_binary` and `get_binary` config options). Put binary should output a handle, that can be used with `get_binary` to retrieve bundle. `put_args` and `get_args` config options can be used to pass additional params to the binaries.


Test Plan:
Change `test-infinitepush-bundlestore.t` test file to point to external store and run it


Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3803936

Tasks: 12479677

Signature: t1:3803936:1473123987:c34987ee459b2a66ee831574a32cdc8231043cb2
2016-09-07 05:20:43 -07:00
Stanislau Hlebik
92e602d7bd infinitepush: bundle store exceptions
Summary: Add exceptions that will be thrown from bundle stores

Test Plan: Run test-infinitepush-bundlestore.t

Reviewers: durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3803928

Tasks: 12479677

Signature: t1:3803928:1473073448:32f6191ea0548c3d83cbaad100b6c8c48cbd8131
2016-09-07 05:16:21 -07:00
Stanislau Hlebik
4be2b5e240 infinitepush: change help messages to match other extensions
Test Plan: Run test-infinitepush-bundlestore.t

Reviewers: durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3810334

Tasks: 12479677

Signature: t1:3810334:1473073423:f39da13eee389d72a72de7322a32b42a8d4ef3af
2016-09-07 05:15:09 -07:00
Stanislau Hlebik
f38b7f9a37 infinitepush: fix date
Test Plan: No need to test - comment change

Reviewers: rmcelroy, durham, mitrandir

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3791555

Tasks: 12479677
2016-08-31 06:14:20 -07:00
Stanislau Hlebik
c55dbabb23 infinitepush: remove mentioning of scratchbranch in help messages
Summary: --create and --to options work with non-scratch bookmarks too

Test Plan: Run test-infinitepush-bundlestore.t

Reviewers: mitrandir, durham, rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3797183

Tasks: 12479677
2016-08-31 06:14:20 -07:00
Stanislau Hlebik
779ffd3fc6 infinitepush: create bundlestore only for local repos
Summary: It's safer to don't have bundlestore then to have uninitialized bundlestore

Test Plan: Run test-infinitepush-bundlestore.t

Reviewers: mitrandir, rmcelroy, durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3797175

Tasks: 12479677
2016-08-31 06:14:20 -07:00
Stanislau Hlebik
812bc05f85 Add get_bookmarks() method
Differential Revision: https://phabricator.intern.facebook.com/D3791007
2016-08-31 01:44:59 -07:00
Stanislau Hlebik
48389f12cc infinitepush: move integration test to the rool level directory
Differential Revision: https://phabricator.intern.facebook.com/D3791446
2016-08-31 01:44:59 -07:00
Stanislau Hlebik
573c1723b1 Use vfs wherever possible
Differential Revision: https://phabricator.intern.facebook.com/D3791002
2016-08-31 01:44:59 -07:00
Stanislau Hlebik
3569253ed8 infinitepush: lint fixes
Summary: {P56601586}

Test Plan: `cd fb-hgext/tests && python ../../hg-crew/tests/run-tests.py test-check-code-hg.t`

Reviewers: rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D3777586

Signature: t1:3777586:1472223173:56da05516a766422f16a5b61046cb8bd95bd67a4
2016-08-26 08:01:30 -07:00
Stanislau Hlebik
977d60e81a infinitepush: sample implementation
Summary:
Copy of hackbranch hackathon project with a few changes.
The goal is to allow saving commits under certain bookmarks in the separate store. These bookmarks are called 'scratch' bookmarks and are defined in config file (for example, 're:scratch/.+').
Scratch commits are sent in a separate bundle2 part during push. During pull new bundle repo is created and requests are served using this bundle repo.

There are a few changes from hackathon project implementation.


  # It requires no changes in mercurial core. It was done by wrapping `findcommonincoming()` function and changing `lookup()` wireproto method (see below).
  # Instead of introducing `listkeypattern()` wireproto method, `lookup()` method and `pull()` command were wrapped. I did it because I thought that it will make code easier. It probably haven't made it easier, it's almost the same. I can change it back to `listkeypattern` if it's necessary.

The bad thing about current implementation is that scratch bookmarks are not downloaded. But in the previous implementation also haven't downloaded bookmark if remotenames is enabled.

There are a couple of problems:
1) As I mentioned before, scratch bookmarks are not downloaded
2) It's impossible to pull both scratch and non-scratch bookmark

Test Plan: python ../../../hg-crew/tests/run-tests.py test-bundlestore.t

Reviewers: durham, rmcelroy, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3750999

Tasks: 12479677

Signature: t1:3750999:1472052396:5d7828566863f0aa437cdc34439ec0759503c6c9
2016-08-26 06:09:01 -07:00
Stanislau Hlebik
019c55f351 infinitepush: indexapi and store
Summary:
Code was written by Laurent, Durham and Mateusz on hackathon.
Index stores metadata, store stores bundles.
This diff adds interfaces and simple filesystem implementations

Test Plan:
cd tests
py.test *.py

Reviewers: durham, rmcelroy, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3741963

Tasks: 12479677

Signature: t1:3741963:1472207457:c9e7fb6163ef3cd6fdc1c4bd5113c623169c3a7c
2016-08-26 04:08:28 -07:00
Stanislau Hlebik
437b663de7 infinitepush: initial commit
Summary: I'll later add most of your hackhaton hackbranch code to this project with a few small fixes

Test Plan: No need

Reviewers: durham, rmcelroy, mitrandir

Reviewed By: rmcelroy, mitrandir

Subscribers: quark, rmcelroy, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D3736089

Signature: t1:3736089:1471876504:98c4efc3bdf66d60f98eed11a3f13bae56fdc716
2016-08-25 09:09:47 -07:00