Mercurial > hg
view tests/test-rename-merge1.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 | d4e62df1c73d |
children | 3a7efcbdf288 |
line wrap: on
line source
$ hg init $ echo "[merge]" >> .hg/hgrc $ echo "followcopies = 1" >> .hg/hgrc $ echo foo > a $ echo foo > a2 $ hg add a a2 $ hg ci -m "start" $ hg mv a b $ hg mv a2 b2 $ hg ci -m "rename" $ hg co 0 2 files updated, 0 files merged, 2 files removed, 0 files unresolved $ echo blahblah > a $ echo blahblah > a2 $ hg mv a2 c2 $ hg ci -m "modify" created new head $ hg merge -y --debug searching for copies back to rev 1 unmatched files in local: c2 unmatched files in other: b b2 all copies found (* = to merge, ! = divergent, % = renamed and deleted): src: 'a' -> dst: 'b' * src: 'a2' -> dst: 'b2' ! src: 'a2' -> dst: 'c2' ! checking for directory renames resolving manifests branchmerge: True, force: False, partial: False ancestor: af1939970a1c, local: 044f8520aeeb+, remote: 85c198ef2f6c note: possible conflict - a2 was renamed multiple times to: c2 b2 preserving a for resolve of b removing a b2: remote created -> g getting b2 b: remote moved from a -> m (premerge) picked tool ':merge' for b (binary False symlink False changedelete False) merging a and b to b my b@044f8520aeeb+ other b@85c198ef2f6c ancestor a@af1939970a1c premerge successful 1 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg status -AC M b a M b2 R a C c2 $ cat b blahblah $ hg ci -m "merge" $ hg debugindex b rev linkrev nodeid p1 p2 0 1 57eacc201a7f 000000000000 000000000000 1 3 4727ba907962 000000000000 57eacc201a7f $ hg debugrename b b renamed from a:dd03b83622e78778b403775d0d074b9ac7387a66 This used to trigger a "divergent renames" warning, despite no renames $ hg cp b b3 $ hg cp b b4 $ hg ci -A -m 'copy b twice' $ hg up eb92d88a9712 0 files updated, 0 files merged, 2 files removed, 0 files unresolved $ hg up 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg rm b3 b4 $ hg ci -m 'clean up a bit of our mess' We'd rather not warn on divergent renames done in the same changeset (issue2113) $ hg cp b b3 $ hg mv b b4 $ hg ci -A -m 'divergent renames in same changeset' $ hg up c761c6948de0 1 files updated, 0 files merged, 2 files removed, 0 files unresolved $ hg up 2 files updated, 0 files merged, 1 files removed, 0 files unresolved Check for issue2642 $ hg init t $ cd t $ echo c0 > f1 $ hg ci -Aqm0 $ hg up null -q $ echo c1 > f1 # backport $ hg ci -Aqm1 $ hg mv f1 f2 $ hg ci -qm2 $ hg up 0 -q $ hg merge 1 -q --tool internal:local $ hg ci -qm3 $ hg merge 2 merging f1 and f2 to f2 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ cat f2 c0 $ cd .. Check for issue2089 $ hg init repo2089 $ cd repo2089 $ echo c0 > f1 $ hg ci -Aqm0 $ hg up null -q $ echo c1 > f1 $ hg ci -Aqm1 $ hg up 0 -q $ hg merge 1 -q --tool internal:local $ echo c2 > f1 $ hg ci -qm2 $ hg up 1 -q $ hg mv f1 f2 $ hg ci -Aqm3 $ hg up 2 -q $ hg merge 3 merging f1 and f2 to f2 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ cat f2 c2 $ cd .. Check for issue3074 $ hg init repo3074 $ cd repo3074 $ echo foo > file $ hg add file $ hg commit -m "added file" $ hg mv file newfile $ hg commit -m "renamed file" $ hg update 0 1 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg rm file $ hg commit -m "deleted file" created new head $ hg merge --debug searching for copies back to rev 1 unmatched files in other: newfile all copies found (* = to merge, ! = divergent, % = renamed and deleted): src: 'file' -> dst: 'newfile' % checking for directory renames resolving manifests branchmerge: True, force: False, partial: False ancestor: 19d7f95df299, local: 0084274f6b67+, remote: 5d32493049f0 note: possible conflict - file was deleted and renamed to: newfile newfile: remote created -> g getting newfile 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg status M newfile $ cd ..