tests/test-revlog.t
author Gregory Szorc <gregory.szorc@gmail.com>
Wed, 26 Sep 2018 14:41:15 -0700
changeset 40389 1b183edbb68e
parent 40281 29b0e9cd02f4
child 45921 95c4cca641f6
permissions -rw-r--r--
repository: teach addgroup() to receive data with missing parents The way the narrow extension works today, the server rewrites outgoing changegroup data to lie about parents when the parents data is missing. It adds the ellipsis flag to the revision so it can be recorded as such in the revlog. In the new wire protocol, such rewriting does not occur on the server (at least not yet anyway). Instead, it is up to the client to recognize when it has received a revision without its parents. This means rewriting will be performed on the client. Furthermore, the mechanism for storing a shallow revision may differ from store to store. For example, the revlog store uses the ellipsis flag to denote a revision's parents have been rewritten. But a non-revlog store may wish to store things differently. And, some stores may not even support receiving shallow revision data! Therefore, it makes sense for the store itself to be making decisions about what to do when they receive revision data without their parents. This commit teaches the addgroup() bulk insert method to accept a boolean argument that indicates whether the incoming data may lack parent revisions. This flag can be set when receiving "shallow" data from a remote. The revlog implementation of this method has been taught to rewrite the missing parent(s) to nullid and to add the ellipsis flag to the revision when a missing parent is encountered. But it only does this if ellipsis flags are enabled on the repo and the incoming data is marked as possibly shallow. An error occurs otherwise. Differential Revision: https://phab.mercurial-scm.org/D5165
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32429
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
     1
  $ hg init empty-repo
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
     2
  $ cd empty-repo
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
     3
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
     4
Flags on revlog version 0 are rejected
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
     5
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
     6
  >>> with open('.hg/store/00changelog.i', 'wb') as fh:
38113
0a10f142299d py3: suppress the output from .write() calls in few tests
Pulkit Goyal <7895pulkit@gmail.com>
parents: 37285
diff changeset
     7
  ...     fh.write(b'\x00\x01\x00\x00') and None
32429
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
     8
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
     9
  $ hg log
32430
36d3559c69a6 revlog: tweak wording and logic for flags validation
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32429
diff changeset
    10
  abort: unknown flags (0x01) in version 0 revlog 00changelog.i!
32429
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    11
  [255]
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    12
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    13
Unknown flags on revlog version 1 are rejected
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    14
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    15
  >>> with open('.hg/store/00changelog.i', 'wb') as fh:
38113
0a10f142299d py3: suppress the output from .write() calls in few tests
Pulkit Goyal <7895pulkit@gmail.com>
parents: 37285
diff changeset
    16
  ...     fh.write(b'\x00\x04\x00\x01') and None
32429
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    17
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    18
  $ hg log
32430
36d3559c69a6 revlog: tweak wording and logic for flags validation
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32429
diff changeset
    19
  abort: unknown flags (0x04) in version 1 revlog 00changelog.i!
32429
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    20
  [255]
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    21
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    22
Unknown version is rejected
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    23
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    24
  >>> with open('.hg/store/00changelog.i', 'wb') as fh:
38113
0a10f142299d py3: suppress the output from .write() calls in few tests
Pulkit Goyal <7895pulkit@gmail.com>
parents: 37285
diff changeset
    25
  ...     fh.write(b'\x00\x00\x00\x02') and None
32429
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    26
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    27
  $ hg log
32430
36d3559c69a6 revlog: tweak wording and logic for flags validation
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32429
diff changeset
    28
  abort: unknown version (2) in revlog 00changelog.i!
32429
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    29
  [255]
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    30
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    31
  $ cd ..
3ea1f1e71a0a tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32410
diff changeset
    32
28656
b6ed2505d6cf parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    33
Test for CVE-2016-3630
b6ed2505d6cf parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
b6ed2505d6cf parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    35
  $ hg init
b6ed2505d6cf parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    36
40281
29b0e9cd02f4 py3: fix test-revlog.t
Mark Thomas <mbthomas@fb.com>
parents: 39908
diff changeset
    37
  >>> import codecs
29b0e9cd02f4 py3: fix test-revlog.t
Mark Thomas <mbthomas@fb.com>
parents: 39908
diff changeset
    38
  >>> open("a.i", "wb").write(codecs.decode(codecs.decode(
36514
71d1bbf1617e py3: add b'' prefixes in tests/test-revlog.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32430
diff changeset
    39
  ... b"""eJxjYGZgZIAAYQYGxhgom+k/FMx8YKx9ZUaKSOyqo4cnuKb8mbqHV5cBCVTMWb1Cwqkhe4Gsg9AD
40281
29b0e9cd02f4 py3: fix test-revlog.t
Mark Thomas <mbthomas@fb.com>
parents: 39908
diff changeset
    40
  ... Joa3dYtcYYYBAQ8Qr4OqZAYRICPTSr5WKd/42rV36d+8/VmrNpv7NP1jQAXrQE4BqQUARngwVA==""",
29b0e9cd02f4 py3: fix test-revlog.t
Mark Thomas <mbthomas@fb.com>
parents: 39908
diff changeset
    41
  ... "base64"), "zlib")) and None
28656
b6ed2505d6cf parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    42
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39307
diff changeset
    43
  $ hg debugrevlogindex a.i
37285
d4e62df1c73d debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37284
diff changeset
    44
     rev linkrev nodeid       p1           p2
d4e62df1c73d debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37284
diff changeset
    45
       0       2 99e0332bd498 000000000000 000000000000
d4e62df1c73d debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37284
diff changeset
    46
       1       3 6674f57a23d8 99e0332bd498 000000000000
39307
da459d426c20 tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38113
diff changeset
    47
da459d426c20 tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38113
diff changeset
    48
  >>> from mercurial import revlog, vfs
da459d426c20 tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38113
diff changeset
    49
  >>> tvfs = vfs.vfs(b'.')
da459d426c20 tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38113
diff changeset
    50
  >>> tvfs.options = {b'revlogv1': True}
da459d426c20 tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38113
diff changeset
    51
  >>> rl = revlog.revlog(tvfs, b'a.i')
da459d426c20 tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38113
diff changeset
    52
  >>> rl.revision(1)
40281
29b0e9cd02f4 py3: fix test-revlog.t
Mark Thomas <mbthomas@fb.com>
parents: 39908
diff changeset
    53
  mpatchError(*'patch cannot be decoded'*) (glob)