Sat, 14 Apr 2018 09:57:44 -0700 hg: pass command intents to repo/peer creation (API)
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 14 Apr 2018 09:57:44 -0700] rev 37717
hg: pass command intents to repo/peer creation (API) The previous commit introduced a mechanism to declare command intents. This commit changes the repository and peer instantiation mechanism so the intents are passed down to each repository and peer type so they can do with them whatever they please. Currently, nobody does anything with any intent. Differential Revision: https://phab.mercurial-scm.org/D3377
Sat, 14 Apr 2018 09:23:48 -0700 registrar: replace "cmdtype" with an intent-based mechanism (API)
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 14 Apr 2018 09:23:48 -0700] rev 37716
registrar: replace "cmdtype" with an intent-based mechanism (API) Commands perform varied actions and repositories vary in their capabilities. Historically, the .hg/requires file has been used to lock out clients lacking a requirement. But this is a very heavy-handed approach and is typically reserved for cases where the on-disk storage format changes and we want to prevent incompatible clients from operating on a repo. Outside of the .hg/requires file, we tend to deal with things like optional, extension-provided features via checking at call sites. We'll either have checks in core or extensions will monkeypatch functions in core disabling incompatible features, enabling new features, etc. Things are somewhat tolerable today. But once we introduce alternate storage backends with varying support for repository features and vastly different modes of behavior, the current model will quickly grow unwieldy. For example, the implementation of the "simple store" required a lot of hacks to deal with stripping and verify because various parts of core assume things are implemented a certain way. Partial clone will require new ways of modeling file data retrieval, because we can no longer assume that all file data is already local. In this new world, some commands might not make any sense for certain types of repositories. What we need is a mechanism to affect the construction of repository (and eventually peer) instances so the requirements/capabilities needed for the current operation can be taken into account. "Current operation" can almost certainly be defined by a command. So it makes sense for commands to declare their intended actions. This commit introduces the "intents" concept on the command registrar. "intents" captures a set of strings that declare actions that are anticipated to be taken, requirements the repository must possess, etc. These intents will be passed into hg.repo(), which will pass them into localrepository, where they can be used to influence the object being created. Some use cases for this include: * For read-only intents, constructing a repository object that doesn't expose methods that can mutate the repository. Its VFS instances don't even allow opening a file with write access. * For read-only intents, constructing a repository object without cache invalidation logic. If the repo never changes during its lifetime, nothing ever needs to be invalidated and we don't need to do expensive things like verify the changelog's hidden revisions state is accurate every time we access repo.changelog. * We can automatically hide commands from `hg help` when the current repository doesn't provide that command. For example, an alternate storage backend may not support `hg commit`, so we can hide that command or anything else that would perform local commits. We already kind of had an "intents" mechanism on the registrar in the form of "cmdtype." However, it was never used. And it was limited to a single value. We really need something that supports multiple intents. And because intents may be defined by extensions and at this point are advisory, I think it is best to define them in a set rather than as separate arguments/attributes on the command. Differential Revision: https://phab.mercurial-scm.org/D3376
Sat, 14 Apr 2018 11:20:38 -0400 cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com> [Sat, 14 Apr 2018 11:20:38 -0400] rev 37715
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp The latter is deprecated on Python 3.7 and causes our tests to fail due to the warning. Differential Revision: https://phab.mercurial-scm.org/D3375
Sat, 14 Apr 2018 11:07:24 -0400 tests: add b prefixes to test-hg-parseurl.py
Augie Fackler <augie@google.com> [Sat, 14 Apr 2018 11:07:24 -0400] rev 37714
tests: add b prefixes to test-hg-parseurl.py Now passes on Python 3. Differential Revision: https://phab.mercurial-scm.org/D3374
Sat, 14 Apr 2018 11:04:58 -0400 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com> [Sat, 14 Apr 2018 11:04:58 -0400] rev 37713
tests: port test-hg-parseurl.py to unittest Differential Revision: https://phab.mercurial-scm.org/D3373
Sat, 14 Apr 2018 01:12:55 -0400 hgwebdir: un-bytes the env dict before re-parsing env
Augie Fackler <augie@google.com> [Sat, 14 Apr 2018 01:12:55 -0400] rev 37712
hgwebdir: un-bytes the env dict before re-parsing env Not the most elegant, but it restores test-subrepo-deep-nested-change.t to passing on Python 3. Differential Revision: https://phab.mercurial-scm.org/D3367
Sat, 14 Apr 2018 16:36:15 -0700 cborutil: implement support for streaming encoding, bytestring decoding
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 14 Apr 2018 16:36:15 -0700] rev 37711
cborutil: implement support for streaming encoding, bytestring decoding The vendored cbor2 package is... a bit disappointing. On the encoding side, it insists that you pass it something with a write() to send data to. That means if you want to emit data to a generator, you have to construct an e.g. io.BytesIO(), write() to it, then get the data back out. There can be non-trivial overhead involved. The encoder also doesn't support indefinite types - bytestrings, arrays, and maps that don't have a known length. Again, this is really unfortunate because it requires you to buffer the entire source and destination in memory to encode large things. On the decoding side, it supports reading indefinite length types. But it buffers them completely before returning. More sadness. This commit implements "streaming" encoders for various CBOR types. Encoding emits a generator of hunks. So you can efficiently stream encoded data elsewhere. It also implements support for emitting indefinite length bytestrings, arrays, and maps. On the decoding side, we only implement support for decoding an indefinite length bytestring from a file object. It will emit a generator of raw chunks from the source. I didn't want to reinvent so many wheels. But profiling the wire protocol revealed that the overhead of constructing io.BytesIO() instances to temporarily hold results has a non-trivial overhead. We're talking >15% of execution time for operations like "transfer the fulltexts of all files in a revision." So I can justify this effort. Fortunately, CBOR is a relatively straightforward format. And we have a reference implementation in the repo we can test against. Differential Revision: https://phab.mercurial-scm.org/D3303
(0) -30000 -10000 -3000 -1000 -300 -100 -30 -10 -7 +7 +10 +30 +100 +300 +1000 +3000 +10000 tip