annotate tests/test-manifest.t @ 40326:fed697fa1734

sqlitestore: file storage backend using SQLite This commit provides an extension which uses SQLite to store file data (as opposed to revlogs). As the inline documentation describes, there are still several aspects to the extension that are incomplete. But it's a start. The extension does support basic clone, checkout, and commit workflows, which makes it suitable for simple use cases. One notable missing feature is support for "bundlerepos." This is probably responsible for the most test failures when the extension is activated as part of the test suite. All revision data is stored in SQLite. Data is stored as zstd compressed chunks (default if zstd is available), zlib compressed chunks (default if zstd is not available), or raw chunks (if configured or if a compressed delta is not smaller than the raw delta). This makes things very similar to revlogs. Unlike revlogs, the extension doesn't yet enforce a limit on delta chain length. This is an obvious limitation and should be addressed. This is somewhat mitigated by the use of zstd, which is much faster than zlib to decompress. There is a dedicated table for storing deltas. Deltas are stored by the SHA-1 hash of their uncompressed content. The "fileindex" table has columns that reference the delta for each revision and the base delta that delta should be applied against. A recursive SQL query is used to resolve the delta chain along with the delta data. By storing deltas by hash, we are able to de-duplicate delta storage! With revlogs, the same deltas in different revlogs would result in duplicate storage of that delta. In this scheme, inserting the duplicate delta is a no-op and delta chains simply reference the existing delta. When initially implementing this extension, I did not have content-indexed deltas and deltas could be duplicated across files (just like revlogs). When I implemented content-indexed deltas, the size of the SQLite database for a full clone of mozilla-unified dropped: before: 2,554,261,504 bytes after: 2,488,754,176 bytes Surprisingly, this is still larger than the bytes size of revlog files: revlog files: 2,104,861,230 bytes du -b: 2,254,381,614 I would have expected storage to be smaller since we're not limiting delta chain length and since we're using zstd instead of zlib. I suspect the SQLite indexes and per-column overhead account for the bulk of the differences. (Keep in mind that revlog uses a 64-byte packed struct for revision index data and deltas are stored without padding. Aside from the 12 unused bytes in the 32 byte node field, revlogs are pretty efficient.) Another source of overhead is file name storage. With revlogs, file names are stored in the filesystem. But with SQLite, we need to store file names in the database. This is roughly equivalent to the size of the fncache file, which for the mozilla-unified repository is ~34MB. Since the SQLite database isn't append-only and since delta chains can reference any delta, this opens some interesting possibilities. For example, we could store deltas in reverse, such that fulltexts are stored for newer revisions and deltas are applied to reconstruct older revisions. This is likely a more optimal storage strategy for version control, as new data tends to be more frequently accessed than old data. We would obviously need wire protocol support for transferring revision data from newest to oldest. And we would probably need some kind of mechanism for "re-encoding" stores. But it should be doable. This extension is very much experimental quality. There are a handful of features that don't work. It probably isn't suitable for day-to-day use. But it could be used in limited cases (e.g. read-only checkouts like in CI). And it is also a good proving ground for alternate storage backends. As we continue to define interfaces for all things storage, it will be useful to have a viable alternate storage backend to see how things shake out in practice. test-storage.py passes on Python 2 and introduces no new test failures on Python 3. Having the storage-level unit tests has proved to be insanely useful when developing this extension. Those tests caught numerous bugs during development and I'm convinced this style of testing is the way forward for ensuring alternate storage backends work as intended. Of course, test coverage isn't close to what it needs to be. But it is a start. And what coverage we have gives me confidence that basic store functionality is implemented properly. Differential Revision: https://phab.mercurial-scm.org/D4928
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 09 Oct 2018 08:50:13 -0700
parents 89630d0b3e23
children 70d2d47314e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12328
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12316
diff changeset
1 Source bundle was generated with the following script:
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12316
diff changeset
2
5406
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
3 # hg init
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
4 # echo a > a
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
5 # ln -s a l
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
6 # hg ci -Ama -d'0 0'
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
7 # mkdir b
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
8 # echo a > b/a
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
9 # chmod +x b/a
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
10 # hg ci -Amb -d'1 0'
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
11
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
12 $ hg init
37437
814e080a1215 commands: document the layering violation in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
13 $ hg unbundle "$TESTDIR/bundles/test-manifest.hg"
814e080a1215 commands: document the layering violation in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
14 adding changesets
814e080a1215 commands: document the layering violation in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
15 adding manifests
814e080a1215 commands: document the layering violation in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
16 adding file changes
814e080a1215 commands: document the layering violation in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
17 added 2 changesets with 3 changes to 3 files
39480
89630d0b3e23 phase: report number of non-public changeset alongside the new range
Boris Feld <boris.feld@octobus.net>
parents: 38543
diff changeset
18 new changesets b73562a03cfe:5bdc995175ba (2 drafts)
37437
814e080a1215 commands: document the layering violation in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
19 (run 'hg update' to get a working copy)
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
20
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
21 The next call is expected to return nothing:
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
22
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
23 $ hg manifest
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
24
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
25 $ hg co
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
26 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
5406
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
27
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
28 $ hg manifest
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
29 a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
30 b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
31 l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
32
22423
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
33 $ hg files -vr .
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
34 2 a
35393
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 23348
diff changeset
35 2 x b/a
22423
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
36 1 l l
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
37 $ hg files -r . -X b
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
38 a
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
39 l
38541
475f5f86eaed files: automatically populate fields referenced from template
Yuya Nishihara <yuya@tcha.org>
parents: 37438
diff changeset
40 $ hg files -T '{path} {size} {flags}\n'
475f5f86eaed files: automatically populate fields referenced from template
Yuya Nishihara <yuya@tcha.org>
parents: 37438
diff changeset
41 a 2
475f5f86eaed files: automatically populate fields referenced from template
Yuya Nishihara <yuya@tcha.org>
parents: 37438
diff changeset
42 b/a 2 x
475f5f86eaed files: automatically populate fields referenced from template
Yuya Nishihara <yuya@tcha.org>
parents: 37438
diff changeset
43 l 1 l
38542
7ae0ea739770 files: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents: 38541
diff changeset
44 $ hg files -T '{path} {node|shortest}\n' -r.
7ae0ea739770 files: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents: 38541
diff changeset
45 a 5bdc
7ae0ea739770 files: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents: 38541
diff changeset
46 b/a 5bdc
7ae0ea739770 files: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents: 38541
diff changeset
47 l 5bdc
22423
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
48
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
49 $ hg manifest -v
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
50 644 a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
51 755 * b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
52 644 @ l
38543
ece3f2d0bbd9 manifest: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents: 38542
diff changeset
53 $ hg manifest -T '{path} {rev}\n'
ece3f2d0bbd9 manifest: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents: 38542
diff changeset
54 a 1
ece3f2d0bbd9 manifest: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents: 38542
diff changeset
55 b/a 1
ece3f2d0bbd9 manifest: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents: 38542
diff changeset
56 l 1
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
57
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
58 $ hg manifest --debug
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
59 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
60 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 755 * b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
61 047b75c6d7a3ef6a2243bd0e99f94f6ea6683597 644 @ l
6737
7239e06e58e9 context: consistently return p1 context for None
Matt Mackall <mpm@selenic.com>
parents: 5406
diff changeset
62
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
63 $ hg manifest -r 0
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
64 a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
65 l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
66
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
67 $ hg manifest -r 1
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
68 a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
69 b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
70 l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
71
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
72 $ hg manifest -r tip
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
73 a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
74 b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
75 l
5155
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
76
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
77 $ hg manifest tip
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
78 a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
79 b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
80 l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
81
14399
71938479eff9 add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents: 14116
diff changeset
82 $ hg manifest --all
37438
7b7ca9ba2de5 commands: don't violate storage abstractions in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37437
diff changeset
83 a
7b7ca9ba2de5 commands: don't violate storage abstractions in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37437
diff changeset
84 b/a
7b7ca9ba2de5 commands: don't violate storage abstractions in `manifest --all`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37437
diff changeset
85 l
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
86
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
87 The next two calls are expected to abort:
5155
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
88
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
89 $ hg manifest -r 2
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
90 abort: unknown revision '2'!
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12253
diff changeset
91 [255]
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
92
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
93 $ hg manifest -r tip tip
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
94 abort: please specify just one revision
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12253
diff changeset
95 [255]