Commit Graph

39 Commits

Author SHA1 Message Date
Durham Goode
7e191da991 treemanifest: don't copy 00manifesttree.d during streaming clones
The old logic that prevented this clone only covered 00manifesttree.i. Let's
also cover 00manifesttree.d.
2017-04-27 12:03:56 -07:00
Jun Wu
2b3b8e46a5 remotefilelog: add filelog methods
Summary:
Filelog methods like `addrevision`, `revision(raw=True)` are needed for flag
processor (lfs) to work correctly. Add them in remotefilelog so lfs wrapper
code could replace them.

Test Plan:
Run existing tests. Stronger tests and lfs integration test will be added when
this area is more complete.

Reviewers: #mercurial, durham, rmcelroy

Reviewed By: durham

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4903959:1493163809:5ebd88fac21d8225a12ce68bfc63a2867ee43769
2017-04-26 19:52:20 -07:00
Jun Wu
0e2c18e2cd remotefilelog: add revlog flags information to the protocol
Summary:
Make the unpacked file format to include the revlog flag information, and make
the getfile(s) protocol support it.

Note: The `getpackv1` protocol and packfile format is not changed yet.

Test Plan:
Run existing tests. Stronger tests and lfs integration test will be added when
this area is more complete.

Reviewers: #mercurial, rmcelroy, durham

Reviewed By: durham

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4903772:1493152451:ab393b0208f0eee199ffc4c8fcfdfd5dd6d0f3ac
2017-04-26 13:08:13 -07:00
Durham Goode
f17ea5b392 treemanifest: add config to not clone tree revlogs during remotefilelog clone
Summary:
Previously a streaming clone would pick up the 00manifesttree.i file. This patch
adds a config to prevent that file (and other meta/ manifests) from being
transfered. The config defaults to False since Google is currently depending on
the previous behavior.

Test Plan: Add a test

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4915481:1492641427:6c8a91da4c8c6e00e23f96a93807d3c426b50532
2017-04-19 21:14:04 -07:00
Durham Goode
902af15d1e remotefilelog: refactor pack wireprotocol to separate file
Summary:
The pack wireprotocol will be useful for exchanging treemanifests, so let's
refactor it out to it's own file. There's a slight protocol change here, where
we terminate the response with 10 null bytes (2 for 0 length filename, 4 for 0
length data, 4 for 0 length history) instead of the original 2 null bytes (for
0 length filename) which didn't let us handle entries with '' as the name.

This pack exchange code isn't even used in production, since most remotefilelog
downloads are done via the lose file (getfile/getfiles) format.

Test Plan:
Ran the tests. Even though this code isn't used in production, the
prefetch and repack tests still cover it.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4860556:1491853521:c3810a4a681606571354b270b957e8df0962c86a
2017-04-10 17:56:01 -07:00
Kostia Balytskyi
0c2d706810 remotefilelog: wrap lz4 imports for compatibility
Differential Revision: https://phabricator.intern.facebook.com/D4707115
2017-03-17 14:02:26 -07:00
Jun Wu
02d79f722e codemod: replace repo.join to repo.vfs.join
Summary: Upstream has deprecated `repo.join`. Let's use `repo.vfs.join` instead.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4704018:1489462391:532b15c24faa33d584f25bb9382c1ff4b2c0c483
2017-03-13 20:51:37 -07:00
Durham Goode
508d4b493b remotefilelog: update to work with manifestlog
Summary:
Upstream has refactored the manifest class, so we need to update remotefilelog
to work with the new structure.

Also fix a mismatch with the new adjustlinkrev signature.

Test Plan: Ran the tests

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4180879:1479285946:d5ac954c495dc8b802d276ab5ac71626a1726612
2016-11-16 12:11:08 -08:00
Durham Goode
f43ba75915 remotefilelog: fix pyflakes and module import errors
Summary:
This fixes all the pyflaks and module errors for the main remotefilelog
code base.

Test Plan: ./run-tests.py test-check* test-remotefilelog*

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4055537:1477049663:ee904d311d17d3659e055e2c109c68c9023cfd1f
2016-10-21 11:02:09 -07:00
Martin von Zweigbergk
71cbc6ab90 treemanifests: include dirlogs in streaming cloning
We need to include the dirlogs (meta/**/00manifest.{i,d}) in streaming
clones for treemanifests to work. Also add a test for it.
2016-08-29 16:19:52 -07:00
Ryan McElroy
f4dd73e113 remotefilelog: pass modern check-code
Test Plan: run-tests.py test-check-code-hg.t

Reviewers: #mercurial, ttung, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Tasks: 12855049

Signature: t1:3777581:1472224785:a15040cec1c95ca60d1be837d905b3c3d87be362
2016-08-26 08:48:07 -07:00
Olivier Trempe
af90628992 flogheads: return an empty list when requesting heads of a non-existing filelog 2016-08-02 10:41:41 -07:00
Olivier Trempe
8005fc4b2f fileserverclient: add wireproto command for requesting a filelog's heads
Allowing discovery of all the heads of a filelog allows supporting some existing
Mercurial use cases, like viewing all the versions of a file in a UI.
2016-08-02 10:40:42 -07:00
Durham Goode
142c8f9f66 packfetch: remove copy metadata from data before sending over the wire
Summary:
In normal Mercurial, the filelog entry's contents contains extra metadata that
stores the copy source. In the new pack format, that information is stored in
the history store, not in the data store. Therefore we need to change the server
side logic that responds to requests for packs to move that information over to
the history side before it sends the data.

Test Plan: Added a test

Reviewers: ttung, mitrandir, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy

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

Signature: t1:3306539:1463609462:0c1e33e0892f96effcc96c8f78401cf0d8ab5cbd
2016-05-20 09:31:34 -07:00
Durham Goode
05ceb8b419 store: basic wire protocol for bundle delivery
Summary:
This adds a new wire protocol command to allow clients to request a set
of file contents and histories from the server and receive them in pack format.
It's pretty simple and always returns all the history for every node requested
(which is a bit overkill), but it's labeled v1 and we can iterate on it.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir

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

Signature: t1:3277212:1463421279:459cc84265502175b47df293647aab7e7a830185
2016-05-16 10:59:09 -07:00
Durham Goode
3817826242 checkcode: fix remotefilelogserver and shallowbundle
Summary: Fix failures found by check-code.

Test Plan: Ran the tests

Reviewers: #sourcecontrol, ttung

Reviewed By: ttung

Differential Revision: https://phabricator.fb.com/D3221373

Signature: t1:3221373:1461648284:23203c17f4a87e33ff4e9be17a8b99bddbcdff05
2016-04-26 13:00:31 -07:00
Durham Goode
2b30eeb96b Fix exception when making a directory that already exists
Summary:
There was a race condition where there could be an exception when trying to
create directories that already exist.

Test Plan: Ran the tests

Reviewers: #sourcecontrol, ttung

Differential Revision: https://phabricator.fb.com/D2736268
2015-12-10 10:11:27 -08:00
Durham Goode
5c49e2b7e4 Change server cache collection strategy
Summary:
Previously we would keep all server cache files for any head in the repo, even
if that head was really old. This resulted in unnecessarily large serve caches.

The new strategy is to keep the files necessary for any commit within the past
25,000 revs or so. Even on repo's with large commit rates this equates to
multiple weeks of time.

Test Plan: Ran the tests

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.fb.com/D2652542
2015-11-13 09:56:52 -08:00
Durham Goode
bb8c595d67 Update to work with latest Mercurial
Upstream Mercurial has made a lot of changes around streaming clones, so we need
to update remotefilelog to handle these new changes.
2015-10-13 14:17:02 -07:00
Durham Goode
e9a9bad998 Use atomic file writes for server side cache
We've gotten reports of users receiving corrupt file blobs directly from the
server. The corruption doesn't enter the cache pool, and we don't get any
further reports of it, so I think it's a transient issue caused certain readers
reading the file before the writer has finished writing it.

Let's use atomic rename files to make this not happen.
2015-09-28 10:31:38 -07:00
Adam Simpkins
a93ebb8b1e remotefilelogserver: fix missing import
Summary:
_walkstreamfiles() uses mercurial.store.decodedir(), so
mercurial.store needs to be imported.

Test Plan:
Confirmed that _walkstreamfiles() no longer throws an exception when cloning a
remote shallow repository.

Reviewers: durham, pyd, rmcelroy

Reviewed By: rmcelroy

Subscribers: net-systems-diffs@, exa, yogeshwer

Differential Revision: https://phabricator.fb.com/D2409648

Signature: t1:2409648:1441245825:00a758f6f0884b77572078589f18592ca6cb6fa4
2015-09-02 19:04:33 -07:00
Durham Goode
fb7827372b Don't check datafiles if the matcher says everything is remote
Streaming clones were taking a while because apparently self.datafiles()
actually stats each .i file instead of just returning the list straight from
fncache. To fix this, let's not call datafiles() when we know the matcher is
going to reject everything anyways.

This significantly speeds up streaming clones.
2015-09-05 12:24:04 -07:00
Augie Fackler
51f7cac5a7 getfile: add error reporting to getfile method
Without this, the only way to report a failure of a file load in a
batched set of getfile requests is to fail the entire batch, which is
potentially painful. Instead, add our own error reporting in-band
which the client can then detect and raise.

I'm not completely happy with the somewhat adhoc error reporting here,
but we expect our server to have at least one additional error ("not
allowed to see file contents") which will require some special
handling on our end, so we need some level of flexibility in the error
reporting protocol so we can extend it later. Sigh.

Open question: should we reserve some range of error codes so that
it's easy for strange custom servers to have related monkeypatches to
client code for custom handling of unforseen-by-remotefilelog
conditions?

I couldn't figure out how to actually get the client to try loading
file contents over http in the test, but the get-with-headers test at
least proves that the server responses look the way I expect.
2015-08-04 14:59:53 -04:00
Augie Fackler
16310f95f3 remotefilelog: introduce new getfile method
Right now, this is a naive fetch-one-file method. The next change will
mark the method as batchable and use a batch in the client so that
many files can be requested in a single RPC.
2015-06-30 17:32:31 -04:00
Augie Fackler
adef2bd2d0 remotefilelogserver: move umask twiddling for cache into _loadfileblob
This narrows the interval during which we've modified umask, which
seems nice. Done as a separate change for clarity.
2015-06-30 16:58:15 -04:00
Augie Fackler
5966446c14 remotefilelogserver: tease out a _loadfileblob method for future use
We're about to introduce a new getfiles method, so let's take this
opportunity to split out the file loading code so it'll be used in
only one place.
2015-06-30 15:02:07 -04:00
Augie Fackler
882ca8e705 remotefilelogserver: prevent getfiles from being called over http at all
This means that even old clients that fail to sniff for capabilities
before trying getfiles will get a sensible error message back from the
server.
2015-06-30 11:04:47 -04:00
Augie Fackler
4e4a3a3a7b remotefilelogserver: disable remotefilelog serving over non-ssh protocols 2015-06-29 16:34:31 -04:00
Augie Fackler
32cb84c8b7 remotefilelogserver: restrict remotefilelog capability to ssh
This only works over ssh, so let's not pretend otherwise.

A future change will ensure the capability is still advertised via ssh.
2015-06-29 17:36:25 -04:00
Augie Fackler
5a72282b12 remotefilelogserver: wrap wireproto._capabilities
If we instead wrap wireproto.capabilities, then our capabilities don't
get transmitted via the hello command, so not all clients will notice
the new capability unless we do the wrapping here.

Test output is in the test that previously demonstrated the
defect. Note that there's still a defect: we're advertising the
capability over http even though we have no hope of the getfiles
method working over http.
2015-06-29 17:35:32 -04:00
Augie Fackler
5eecca9702 remotefilelog: handle the death of repo.sopener (hg change 0bbe3294361a)
repo.sopener has been deprecated since hg 2.3, and repo.svfs replaces
it. Since it's been dead for so long, let's just use svfs and call it
good enough.
2015-06-30 10:12:38 -04:00
Durham Goode
047afeff5f hooks: remove incominghook
Summary:
The incominghook was meant to pregenerate any remotefilelog blobs that were
likely to be needed shortly. Unfortunately it actually just slows down pushes,
since in large repos the hook takes longer than the push does sometimes.

So let's just remove it.

Test Plan: Apparently there were no tests for this :p

Reviewers: sid0, lcharignon, mitrandir, ericsumner, rmcelroy

Reviewed By: rmcelroy

Differential Revision: https://phabricator.fb.com/D2185894

Signature: t1:2185894:1435126819:e1e1125520411356eccff4baee31ab2938ebc0fe
2015-06-23 20:03:57 -07:00
Durham Goode
93e4a455ff clone: fix streaming clones
Upstream refactored the streaming clone api, so we need to adjust accordingly.
2015-05-27 17:29:34 -07:00
Durham Goode
acea316460 Fix blob generation with adjustlinkrevs
Summary:
When adjustlinkrevs got moved to the filectx upstream, we incorrectly
moved it to the remotefilectx inside remotefilelog. We don't actually use
remotefilectx on the server, so wrapping it did nothing.

The fix is to move the wrapping to be in remotefilelogserver.py so it is
executed on the server side.

Test Plan:
Did a checkout with my shallow client pointed at a full repo with no
blob cache. Verified it went quickly (minutes, instead of hours).

Reviewers: pyd

Differential Revision: https://phabricator.fb.com/D2097851
2015-05-22 21:32:12 -07:00
Durham Goode
f84dcdee5d Move _adjustlinkrev onto remotefilectx
Summary:
Upstream has moved _adjustlinkrev from being a global function to one
on the filectx. Let's do the same.

Test Plan: Ran the tests

Reviewers: mitrandir

Differential Revision: https://phabricator.fb.com/D1825043
2015-02-03 18:59:00 -08:00
Durham Goode
07359d1038 Change server blob creation to not use adjustlinkrev
Summary:
adjustlinkrev makes ancestor reading orders of magnitude slower,
so we need to avoid using it. Since adjustlinkrev already returns the linkrev in
certain cases, let's just force it to always return that during file blob
creation.

Test Plan:
Generated a few thousand blobs for www and fbcode using the old and new
methods and verified that they were byte-for-byte identical.

Reviewers: sid0, pyd, mpm, rmcelroy

Differential Revision: https://phabricator.fb.com/D1782400
2015-01-14 13:14:35 -08:00
Durham Goode
580f3eaeb3 Update to match Mercurial version b8c8cacd4482
Summary:
Changegroups have been refactored upstream and we need to update our
remotefilelog monkey patching accordingly.

Also fix an issue with the tests where 'function foo()' was not considered valid
on certain systems.

Test Plan: Ran the tests

Reviewers: pyd, sid0, davidsp

Differential Revision: https://phabricator.fb.com/D1551019
2014-09-11 14:39:14 -07:00
Durham Goode
92d01b616c Allow readonly access to remotefilelog cache
Summary:
Previously requesting remotefilelog file blobs from the server required write
access in order to write the blob to the cache. This changes it to not abort
entirely if the user doesn't have write access.

Test Plan:
cd tests
./run-tests.py --with-hg=/data/users/durham/hg/hg test-permissions.t
Also ran the test without the fix and verified it fails.

Reviewers: sid0, davidsp, pyd, dschleimer

Reviewed By: dschleimer

Differential Revision: https://phabricator.fb.com/D1145976

Task ID: 3601184
2014-01-27 17:09:48 -08:00
Durham Goode
85e48b58fd Move server and debug logic into their own files
__init__.py was getting quite large. This change moves the server and debug
logic into their own files.  Client-side logic remains in __init__.py
2013-11-25 16:36:44 -08:00