Commit Graph

117 Commits

Author SHA1 Message Date
Durham Goode
a4c87d13eb test: fix bad test output
There are two tests around shallow-to-shallow pulls. One for local pulls and one
for ssh pulls.  The local pulls correct showed that two base revs should be
fetched (one for the base of the x changes, and one for the base of the y
changes). The ssh pull test incorrectly marked this as 4 and it was failing for
me.

This implies that at some point it was actually fetching 4 items, but given that
the master repo only has two commits, and that they only touch files x and y,
I'm not sure how 4 is possible, so changing it to two seems to be strictly
better.
2016-05-18 07:30:03 -07:00
Durham Goode
65a4e0eab6 test: add sort to all find commands
Summary:
Turns out the find output is not deterministic, so it was producing different
results in some environments. Let's throw in a sort call for all find output.

Test Plan: Ran the tests

Reviewers: mitrandir, #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D3306533
2016-05-18 07:22:10 -07:00
Durham Goode
56411349f7 datapack: make fanout size dynamic
Summary:
Previously all fanout tables were 2^16 in length. For small packs, this resulted
in very sparse fanout tables that had to be linearly scanned to find the end of
the search bounds, which was slow.

With this patch, the data index now dynamically chooses what fanout table size
to use.  If the pack has over 2^16 / 10 entries, we use 2^16, otherwise we use
2^8. The reasoning is in the code.

The patch is a bit large because we had to take a bunch of constants and
duplicate them, and change their accessors to access them through member
variables.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir

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

Signature: t1:3279000:1463170357:9746d19dde14743bac9a8c40cafbc618504c420f
2016-05-16 10:59:09 -07:00
Durham Goode
c9621d3d1a repack: don't require complete history during data repack
Summary:
Previously, when repacking deltas we would require a full history of the node so
we could order the hashes optimally. In some situations though, we don't have
the full history available (like if we're only repacking a subset of packs), so
we need to be able to repack even without full history.

This patch handles the case where a given delta doesn't have history
information. We just store it as a full text.

This becomes useful in an upcoming series that will introduce incremental
packing that only packs a subset of the packs.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3278346:1463086170:54c0fbefe78f9cafa7efc4b6f037887a924ab4a5
2016-05-16 10:59:09 -07:00
Durham Goode
e13e9ef243 historypack: fix handling of section lookup key errors
Summary:
In the old days _findsection would return None if the section wasn't found. We
have since changed it to throw a KeyError like all the other operations in the
packs. We need to update getmissing to eat that error like usual.

Test Plan: ran the repack that was failing, it succeeded.  Added a unit test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3277245:1463085831:0b32f852f49bd45ef2dfd3298313b9c2b87f75b6
2016-05-16 10:59:09 -07:00
Durham Goode
5e4370b46d packs: add debug commands to view pack contents
Summary: Some simple debug commands to print the contents of each pack.

Test Plan: Ran it manually, and added a simple test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3277233:1463085196:c54fc875d536a96150bb1461b77247a5d7a9402c
2016-05-16 10:59:09 -07:00
Durham Goode
e617c24532 datapack: add index marker for no delta base
Summary:
Previously, we assumed every delta in a pack had a complete chain in that pack,
so the index had no way to indicate a deltabase offset that didn't exist in the
pack.

Let's add a new marker to indicate that the delta base doesn't exist in this
pack.

Test Plan: Tested in my large repo repack scenario.  Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3277222:1463084346:1687cfa174e98c2cf3022de9e9c3808881f689cd
2016-05-16 10:59:09 -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
2a938a761c store: add copyfrom information to history index
Summary:
Previously we were throwing away copy information when we repacked things into
pack files. The hope was that we could store copy information somewhere else,
and keep the history pack using fixed length entries. Since storing copy
information elsewhere is a long ways off, let's just go ahead and put copy info
in the pack file.

This makes the entries non-fixed length, which means any iteration over them has
to read the length of each entry. This also affects the historypack filename
hashes since they are content based, so the tests had to change.

This matches the old remotefilelog behavior more closely (which is why no code
had to change outside the pack logic).

Test Plan: Added a test

Reviewers: #mercurial, mitrandir, ttung

Reviewed By: mitrandir

Subscribers: mitrandir

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

Signature: t1:3262185:1462562602:935683692276c7fa569d381b18aa3b18656793b1
2016-05-16 10:59:09 -07:00
Durham Goode
e4fb7d66bb history: remove getparents and getlinknode apis
Summary:
These APIs weren't actually used, and the questions can be answered via
the existing getancestors() api anyway.

They were originally put in place because they are the type of question that
doesn't require the full ancestor tree, so we could answer them without doing in
traversal. In an upcoming patch we add the concept of copyfrom back into the
historypack, and getparents becomes confusing since it doesn't expose knowledge
of copy information. So I just decided to delete it all until we need it.

In the future we may want a 'gethistoryinfo(filename, node)' api that just
returns (p1, p2, linknode, copyfrom), to fulfill that original need of history
information without a full ancestor traversal.

Test Plan: Ran the tests

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3261734:1462413665:987c4703e53468a75346aa323188107a5c070fde
2016-05-16 10:59:09 -07:00
Durham Goode
ce493adf83 repack: add --background option
Summary:
This allows triggering a repack that can be run in the background. In the future
we will trigger this automatically under certain circumstances (like too many
pack files).

Test Plan: Added a test

Reviewers: #mercurial, ttung, quark

Reviewed By: quark

Subscribers: quark

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

Signature: t1:3261161:1462398568:5ae25f3e5a9acd0f4b34490b34a62be33cc69e3c
2016-05-04 14:53:23 -07:00
Durham Goode
8e290a5d4a repack: add lock to limit it to only one repack
Summary:
This adds a lock that limits us to running only one repack at a time. We also
add a simple prerepack hook to allow the tests to insert a sleep to test this
functionality.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3260428:1462393311:3e1bf5dd047e7f3521679ca7640b448f5e784913
2016-05-04 14:53:19 -07:00
Durham Goode
c2cdcde2fb store: read recent packs first
Summary:
Since recent packs are likely to contain more recent data, let's put them at the
front of the pack list so they are checked first.

In a future diff I'll come back and refact the common code between datapack and
historypack into one base class.

Test Plan:
Ran the tests. Used the debugger to verify that the sort order was
correct.

Reviewers: #mercurial, ttung, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

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

Signature: t1:3259823:1462388395:8ee48a7b02c6abc079878e53c5b336675249cb91
2016-05-04 14:53:16 -07:00
Durham Goode
7da17af64f store: record what files were created during a repack
Summary:
Previously, if you ran repack twice in a row, it would actually delete your
packs, because the repack produced files with the same name as before, and the
cleanup then deleted them.

The fix is to have the stores record what files they produced in the ledger,
then future clean up work can avoid deleting anything that was created during
the repack.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir

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

Signature: t1:3255819:1462393814:d32155b12535990f72fbe48de045eddbb6f7fab6
2016-05-04 14:53:10 -07:00
Durham Goode
30cc85653c store: make pack files read-only
Summary:
Since pack files should never change after they are created, let's create them
with read-only permissions. It turns out that the Mercurial vfs doesn't apply
the correct permissions to files created by mkstemp (and we have to use mkstemp
since we don't know the name of the file until after we've written all the data
to it), so we have to manually call the permission fixing code.

We also need to fix our mmap calls to be readonly now, otherwise we get a
runtime permission denied exception.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3255816:1462321201:dff4fb4c9301d67a77043ecc1d96262bb5d6a54a
2016-05-04 14:53:07 -07:00
Durham Goode
1d4b4dbb36 store: switch mutable packs to use openers
Summary:
Instead of passing in a path and performing joins ourselves, let's use an
opener. This will help handle all the file permission edge cases.

Test Plan: Ran the tests

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3255165:1462393836:38a28c850a0dc06838d9c17672d3dffd9903bbd7
2016-05-04 14:53:04 -07:00
Durham Goode
ed6a2e06c3 store: add a test for repacking packs
Summary:
This adds a test for 'hg repack' in the case where some data exists in packs,
and some data exists in loose objects. We expect the old packs and objects to be
cleaned up, and one new datapack and historypack to remain.

Test Plan: Ran it

Reviewers: lcharignon, ttung, rmcelroy, quark, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3251545:1462315943:fbe9f76322587d2c19bc753d97d8f809b1e13ca2
2016-05-04 14:52:52 -07:00
Durham Goode
6b25f32192 store: add revision count to historypack filesection
Summary:
Previously, given a historypack file, we had no way of reading the contents,
since we had no way to know when to stop reading the revision entries for a
given file section.

This patch changes the format to have a revision count value after the filename
and before the revisions. The documentation already documented the format like
this, and therefore doesn't need updating.

A future patch will use this information to iterate over all the revisions in
the pack.

Test Plan: Added a test in a future patch

Reviewers: lcharignon, ttung, rmcelroy, quark, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3251538:1462393282:f46b50e79237bfa8a25ff1957344588622b2699a
2016-05-04 14:52:43 -07:00
Durham Goode
948fad28a8 store: add simple test for repack
Summary:
This adds a simple test for repack that ensures the old blobs are cleaned up and
the new data is still accessible.

Test Plan: Ran the tests

Reviewers: lcharignon, ttung, rmcelroy, quark, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3250673:1462235487:bcb5015b9a3665c5bb54776de6d110b1b8a64078
2016-05-04 14:52:37 -07:00
Durham Goode
4ecb47b021 store: move history repack logic to repacker
Summary:
We had a naive repack implementation in historypack.py. Let's move it to the
repack module and do the minor adjustments to use the new repackerledger apis.

Test Plan:
Ran hg repack in conjunction with future diffs that make use of this
api

Reviewers: rmcelroy, ttung, lcharignon, quark, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3249587:1462232544:591cd8bec09f781370896470746eae5a4489531f
2016-05-03 12:33:54 -07:00
Durham Goode
735aa964d5 store: move data repack logic to repacker
Summary:
We had a naive repack implementation in datapack.py. Let's move it to the repack
module and do the minor adjustments to use the new repackerledger apis.

Test Plan: Ran it in conjunction with future diffs that make use of this api.

Reviewers: rmcelroy, ttung, lcharignon, quark, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3249585:1462232504:a00aa65afca9562a2c1456cc4ab48c50d1ba5b68
2016-05-03 12:33:36 -07:00
Durham Goode
6d68bef157 store: add perf test
Summary:
Adds an optional test for performance profiling. Using this test I was
able to see the difference between bisect, interpolation search, and the fanout
table on the index lookup times, and determined the fanout table was about 10x
faster on packs with 1 million objects.

It also taught me that the 2^16 fanout table is very inefficient for small packs
(cpu wise), so we should allow it to be configurable.

Test Plan: Ran it

Reviewers: rmcelroy, ttung, lcharignon, quark, mitrandir

Reviewed By: mitrandir

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

Signature: t1:3249574:1462240719:b8895f79895286613261cd2d4314c214688558eb
2016-05-03 12:32:16 -07:00
Durham Goode
1704e5c8fb store: add tests for historypack
Summary:
This adds a basic test suite for the historypack class, and fixes some issues it
found.

Test Plan: ./run-tests.py test-historypack.py

Reviewers: mitrandir, rmcelroy, ttung, lcharignon

Reviewed By: lcharignon

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

Signature: t1:3237858:1461884966:c0ec90a2735255e5ef70eade09915066a7b71ee5
2016-04-28 17:37:03 -07:00
Durham Goode
0244f5460a store: add unit tests for datapack classes
Summary: This adds some basic unit tests for creating and reading from datapack files.

Test Plan: ./run-tests.py test-datapack.py

Reviewers: mitrandir, rmcelroy, lcharignon

Differential Revision: https://phabricator.intern.facebook.com/D3233181
2016-04-28 15:00:34 -07:00
Durham Goode
22948ce7e1 checkcode: add check code test
Summary: Adds the same check code test that upstream Mercurial uses.

Test Plan:
Ran it, and fixed all the failures. I won't land this commit until
all the failure fixes are landed.

Reviewers: #sourcecontrol, ttung, rmcelroy, wez

Reviewed By: wez

Subscribers: quark, rmcelroy, wez

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

Signature: t1:3221380:1461802769:19f5bdc209c05edb442faa70ae572ce31e2fbc95
2016-04-28 10:18:47 -07:00
Durham Goode
9440072474 checkcode: fix tests
Summary: Fix failures found by check-code.

Test Plan: Ran the tests

Reviewers: #sourcecontrol, ttung

Subscribers: ps

Differential Revision: https://phabricator.fb.com/D3221377
2016-04-26 13:00:31 -07:00
Durham Goode
84bc49f25d checkcode: fix shallowrepo, shallowutil, and setup.py
Summary: Fix failures found by check-code.

Test Plan: Ran the tests

Reviewers: #sourcecontrol, ttung

Reviewed By: ttung

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

Signature: t1:3221375:1461648312:7dbdd59e6370cb32b90d864a623d8066028741e7
2016-04-26 13:00:31 -07:00
Durham Goode
2d1dcb4b97 Fix missing 'grp' import 2016-04-18 11:46:06 -07:00
Durham Goode
5b2914142a Fix status returning invalid results
The recent refactor caused remotefilelog.size() to include rename metadata in
the size count, which meant the size didn't match what the rest of Mercurial
expected. This caused clean files to show up as dirty in hg status if they had a
'lookup' dirstate state and were renames.
2016-04-10 09:46:24 -07:00
Durham Goode
492b9af06e ioutil: move helper functions to ioutil
Future patches will refactor the storage into more abstract APIs. Let's move
these utility functions out to be on their own.
2016-04-04 16:26:12 -07:00
Jun Wu
be261ba980 Fix tests for chg
Summary:
When running tests under chg, the server process won't exit per command.
Change tests to make them chg-friendly.

Test Plan:
Run tests with latest chg (with some additional patches not in core yet)

  cd ~/remotefilelog/tests
  ~/hg/tests/run-tests.py --chg

Reviewers: #sourcecontrol, ttung, durham

Reviewed By: durham

Subscribers: durham

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

Signature: t1:3026087:1457546610:bd469e51a50dbe49505afd661848b7280feacb53
2016-03-22 10:45:18 -07:00
Ryan McElroy
d839113ded more leniency for slow network
Summary:
I saw a test failure on a loaded box where we got a low enough
throughput to write out "bytes/sec" instead of "KB/sec".

Test Plan: run all tests

Reviewers: #sourcecontrol, ttung, durham

Reviewed By: durham

Subscribers: durham

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

Signature: t1:3018195:1457379358:24cd762f4c2788b49bc6fa409f6a935f37a70980
2016-03-08 03:47:33 -08:00
Wez Furlong
2ec314e26a remotefilelog: add separate option to validate localcache files
Summary:
We've recently had to dig into two different issues that resulted in broken
files landing in the localcache; one was due to a problem with the data source
for our cacheprocess becoming corrupt and the other was due to a failed write
(ENOSPC) causing a truncated file to be left in the local cache.

It is desirable to perform some lightweight consistency checks before we return
data up to the caller of localcache, but prior to this diff the validation
functionality was coupled to configuring a log file.

Due to the shared nature of the localcache it's not always clear cut where we
want to log localcache consistency issues, so it feels more flexible to
decouple logging from enabling checks.

This diff introduces `remotefilelog.validatecache` as a separate option that
can have three values:

* `off` - no checks are performed
* `on` - checks are performed during read and write
* `strict` - checks are performed during __contains__, read and write

The default is now `on`.

Test Plan: `./run-tests.py --with-hg=../../hg-crew/hg`

Reviewers: #sourcecontrol, ttung

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

Tasks: 10044183, 9987694
2016-02-18 08:34:33 -08:00
Augie Fackler
6a4b66c8cc test-cacheprocess: add a new test that demonstrates talking to a cacheprocess
Right now this only demonstrates reading from the cache. Writing is
not currently implemented. This tests both the cache-hit and
cache-miss case for both of including the file path and not in the
cache request.
2016-02-08 14:42:14 -08:00
Durham Goode
4ee8e7278d changegroup: support new _packermap name
Upstream changed changegroup.packermap to be changegroup._packermap. So we need
to update accordingly.
2016-01-19 16:34:53 -08:00
Durham Goode
77a1e268d2 tests: update tests to include cg3 in header
Upstream added a new changegroup format, so our headers changed slightly.
2016-01-19 16:34:20 -08:00
Stanislau Hlebik
33b7e1013a remotefilelog: make .hg/store/data blobs read only
Summary:
Today, people running codemods or search/replace on their repos often accidentally corrupt their repos, and everyone ends up sad.
It's better to make them read-only

Test Plan: python run-tests.py

Reviewers: rmcelroy, #sourcecontrol, durham, ttung

Reviewed By: durham

Subscribers: mitrandir, quark, durham

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

Tasks: 9431187

Signature: t1:2807369:1452192329:b5ed6606cb66b1c830fc3d3fb5a81e6120387b38
2016-01-07 13:37:36 -08:00
Durham Goode
422b0cece0 tests: fix packermap dependency with upstream
Upstream added a changegroup3 format, and the test needs to account for that.
2016-01-04 14:59:10 -08:00
Laurent Charignon
d6539aeb26 test: change output of test-http.t
Summary:
This seems similar to t9539553, the patch is just the change of the
test output, it seems like we changed some bundle related code in core.

Test Plan: test pass

Reviewers: ericsumner, durham

Differential Revision: https://phabricator.fb.com/D2794159
2015-12-30 12:39:14 -08:00
Laurent Charignon
a2e1b43251 test-gc: fix test and make it more robust 2015-12-29 12:47:57 -08:00
Durham Goode
cb448f683b Stop writing backup local data blobs
Summary:
Historicaly we would move the old backup data blob to <name>+<int> so we had a
record of all the old data blobs we could search though for good commit
histories.

Since we no longer require that the data blobs have perfect commit histories,
these extra blobs just take up space.

This changes makes us only store one old version (for debugging and recovery
purposes), which should save space on clients.

Also switched to atomic rename writes while we're at it.

Test Plan: Ran the tests

Reviewers: #sourcecontrol, ttung

Differential Revision: https://phabricator.fb.com/D2770675
2015-12-17 13:02:29 -08:00
Durham Goode
bd3303b6bb Update test now that checkunknown fetches less
The previous commit reduced the amount of fetches were done in sparse checkouts,
so we need to update the test too.
2015-12-16 13:22:56 -08:00
Durham Goode
b3b4ddc20b Prefetch before addremove check
Summary:
When running addremove, it needs to see the contents of the removed files so it
can determine if they are a remain. So we need to add bulk prefetching in this
situation.

Test Plan: Added a test

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: dcapra

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

Signature: t1:2756979:1450132279:668b8b160d792cad1ac37e2069716e20ea304f57
2015-12-14 14:44:11 -08:00
Durham Goode
faccfe65d4 Add prefetching to checklookup
Summary:
During hg status Mercurial sometimes needs to look at the size of contents of
the file and compare it to what's in history, which requires the file blob.

This patch causes those files to be batch downloaded before they are compared.

There was a previous attempt at this (see the deleted code), but it only wrapped
the dirstate once at the beginning, so it was lost if the dirstate object was
replaced at any point.

Test Plan: Added a test to verify unknown files require only one fetch.

Reviewers: #sourcecontrol, ttung

Reviewed By: ttung

Subscribers: dcapra

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

Signature: t1:2756768:1450130997:7c7101efe66c998e3182dfbd848aa6b1a57d509f
2015-12-14 14:44:08 -08:00
Durham Goode
4a5ae177bb Add prefetching for checkunknownfiles
Summary:
When doing an update, Mercurial checks if unknown files on disk match
what's in memory, otherwise it stops the checkout so it doesn't cause data loss.

We need to batch fetch the necessary files from the remotefilelog server for
this operation.

Test Plan: Added a test

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: dcapra

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

Signature: t1:2756837:1450132288:bc0530a07ea40aaeb2af1a93e4da82778cc11369
2015-12-14 14:49:34 -08:00
Martin von Zweigbergk
0ac1cffabd drop unnecessary "format.generaldelta=True" now that it's the default 2015-12-10 17:25:14 -08:00
Laurent Charignon
7431e97098 remotefilelog: fix tests so that they work on devservers too 2015-12-09 16:55:05 -08:00
Eric Sumner
64aa941995 generaldelta config name change 2015-12-08 09:55:15 -08:00
Eric Sumner
9d009eb59f generaldelta now on by default 2015-12-08 09:55:10 -08:00
Laurent Charignon
c89f602b7d gcclient: guard against malformed repo paths
Before this patch, gc would stop on malformed repo path. When this happens
we want to know what happened and get useful debugging information.
2015-12-02 10:40:49 -08:00