tests/test-requires.t
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 48876 42d2b31cee0b
child 49969 84680c003d44
permissions -rw-r--r--
procutil: make stream detection in make_line_buffered more correct and strict In make_line_buffered(), we don’t want to wrap the stream if we know that lines get flushed to the underlying raw stream already. Previously, the heuristic was too optimistic. It assumed that any stream which is not an instance of io.BufferedIOBase doesn’t need wrapping. However, there are buffered streams that aren’t instances of io.BufferedIOBase, like Mercurial’s own winstdout. The new logic is different in two ways: First, only for the check, if unwraps any combination of WriteAllWrapper and winstdout. Second, it skips wrapping the stream only if it is an instance of io.RawIOBase (or already wrapped). If it is an instance of io.BufferedIOBase, it gets wrapped. In any other case, the function raises an exception. This ensures that, if an unknown stream is passed or we add another wrapper in the future, we don’t wrap the stream if it’s already line buffered or not wrap the stream if it’s not line buffered. In fact, this was already helpful during development of this change. Without it, I possibly would have forgot that WriteAllWrapper needs to be ignored for the check, leading to unnecessary wrapping if stdout is unbuffered. The alternative would have been to always wrap unknown streams. However, I don’t think that anyone would benefit from being less strict. We can expect streams from the standard library to be subclassing either io.RawIOBase or io.BufferedIOBase, so running Mercurial in the standard way should not regress by this change. Py2exe might replace sys.stdout and sys.stderr, but that currently breaks Mercurial anyway and also these streams don’t claim to be interactive, so this function is not called for them.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13956
ffb5c09ba822 tests: remove redundant mkdir
Martin Geisler <mg@lazybytes.net>
parents: 12346
diff changeset
     1
  $ hg init t
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     2
  $ cd t
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     3
  $ echo a > a
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     4
  $ hg add a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12116
diff changeset
     5
  $ hg commit -m test
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     6
  $ rm .hg/requires
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     7
  $ hg tip
47157
3a9f3470922c revlog: use revlog.display_id in format related errors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46884
diff changeset
     8
  abort: unknown version (65535) in revlog 00changelog
46116
17a695357270 errors: use detailed exit code 50 for StorageError
Martin von Zweigbergk <martinvonz@google.com>
parents: 45906
diff changeset
     9
  [50]
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
    10
  $ echo indoor-pool > .hg/requires
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
    11
  $ hg tip
45906
95c4cca641f6 errors: remove trailing "!" from some error messages for consistency
Martin von Zweigbergk <martinvonz@google.com>
parents: 45107
diff changeset
    12
  abort: repository requires features unknown to this Mercurial: indoor-pool
26421
4b0fc75f9403 urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents: 20820
diff changeset
    13
  (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12156
diff changeset
    14
  [255]
14746
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    15
  $ echo outdoor-pool >> .hg/requires
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    16
  $ hg tip
45906
95c4cca641f6 errors: remove trailing "!" from some error messages for consistency
Martin von Zweigbergk <martinvonz@google.com>
parents: 45107
diff changeset
    17
  abort: repository requires features unknown to this Mercurial: indoor-pool outdoor-pool
26421
4b0fc75f9403 urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents: 20820
diff changeset
    18
  (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
14746
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    19
  [255]
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    20
  $ cd ..
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    21
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    22
Test checking between features supported locally and ones required in
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    23
another repository of push/pull/clone on localhost:
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    24
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    25
  $ mkdir supported-locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    26
  $ cd supported-locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    27
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    28
  $ hg init supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    29
  $ echo a > supported/a
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    30
  $ hg -R supported commit -Am '#0 at supported'
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    31
  adding a
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    32
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    33
  $ echo 'featuresetup-test' >> supported/.hg/requires
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    34
  $ cat > $TESTTMP/supported-locally/supportlocally.py <<EOF
33985
68bc85f46fe3 tests: update test-requires to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 32392
diff changeset
    35
  > from mercurial import extensions, localrepo
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    36
  > def featuresetup(ui, supported):
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    37
  >     for name, module in extensions.extensions(ui):
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    38
  >         if __name__ == module.__name__:
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    39
  >             # support specific feature locally
40229
fed5e57c8dc7 py3: add a b'' prefix in tests/test-requires.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 37135
diff changeset
    40
  >             supported |= {b'featuresetup-test'}
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    41
  >             return
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    42
  > def uisetup(ui):
37135
ecac0006b90e localrepo: move featuresetupfuncs out of localrepository class (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33985
diff changeset
    43
  >     localrepo.featuresetupfuncs.add(featuresetup)
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    44
  > EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    45
  $ cat > supported/.hg/hgrc <<EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    46
  > [extensions]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    47
  > # enable extension locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    48
  > supportlocally = $TESTTMP/supported-locally/supportlocally.py
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    49
  > EOF
45107
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 40229
diff changeset
    50
  $ hg -R supported debugrequirements
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 40229
diff changeset
    51
  dotencode
48321
f35529784079 dirstate-v2: fix confusion between requirement and format config variable
Raphaël Gomès <rgomes@octobus.net>
parents: 48295
diff changeset
    52
  dirstate-v2 (dirstate-v2 !)
45107
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 40229
diff changeset
    53
  featuresetup-test
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 40229
diff changeset
    54
  fncache
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 40229
diff changeset
    55
  generaldelta
46884
cc3ad5c3af3b persistent-nodemap: enable the feature by default when using Rust
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46874
diff changeset
    56
  persistent-nodemap (rust !)
46874
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46406
diff changeset
    57
  revlog-compression-zstd (zstd !)
45107
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 40229
diff changeset
    58
  revlogv1
48669
7ee07e1a25c0 share-safe: enable by default (BC)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48321
diff changeset
    59
  share-safe
45107
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 40229
diff changeset
    60
  sparserevlog
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 40229
diff changeset
    61
  store
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    62
  $ hg -R supported status
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    63
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    64
  $ hg init push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    65
  $ hg -R supported push push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    66
  pushing to push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    67
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    68
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    69
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    70
  $ hg init pull-src
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    71
  $ hg -R pull-src pull supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    72
  pulling from supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    73
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    74
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    75
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    76
  $ hg clone supported clone-dst
45906
95c4cca641f6 errors: remove trailing "!" from some error messages for consistency
Martin von Zweigbergk <martinvonz@google.com>
parents: 45107
diff changeset
    77
  abort: repository requires features unknown to this Mercurial: featuresetup-test
26421
4b0fc75f9403 urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents: 20820
diff changeset
    78
  (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    79
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    80
  $ hg clone --pull supported clone-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    81
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    82
  [255]
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 14746
diff changeset
    83
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 14746
diff changeset
    84
  $ cd ..