tests/test-merge5.t
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 45840 527ce85c2e60
child 49621 55c6ebd11cb9
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:
11978
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
     1
  $ hg init
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
     2
  $ echo This is file a1 > a
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
     3
  $ echo This is file b1 > b
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
     4
  $ hg add a b
12155
94ad12aa0530 test-merge5: removed unnecessary parts of test
Martin Geisler <mg@lazybytes.net>
parents: 12154
diff changeset
     5
  $ hg commit -m "commit #0"
11978
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
     6
  $ echo This is file b22 > b
12155
94ad12aa0530 test-merge5: removed unnecessary parts of test
Martin Geisler <mg@lazybytes.net>
parents: 12154
diff changeset
     7
  $ hg commit -m "comment #1"
11978
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
     8
  $ hg update 0
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
     9
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
    10
  $ rm b
12155
94ad12aa0530 test-merge5: removed unnecessary parts of test
Martin Geisler <mg@lazybytes.net>
parents: 12154
diff changeset
    11
  $ hg commit -A -m "comment #2"
11978
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
    12
  removing b
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
    13
  created new head
12154
c85e07a2d783 test-merge5: ensure updating to tip across branches is tested
Brodie Rao <brodie@bitheap.org>
parents: 11978
diff changeset
    14
  $ hg update 1
c85e07a2d783 test-merge5: ensure updating to tip across branches is tested
Brodie Rao <brodie@bitheap.org>
parents: 11978
diff changeset
    15
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
17849
6da47b655d97 update: check for missing files with --check (issue3595)
Matt Mackall <mpm@selenic.com>
parents: 14485
diff changeset
    16
  $ rm b
28065
6b1fc09c699a update: change default destination to tipmost descendant (issue4673) (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28029
diff changeset
    17
  $ hg update -c 2
19801
41abe2e3e3b7 update: standardize error message for dirty update --check
Siddharth Agarwal <sid0@fb.com>
parents: 19799
diff changeset
    18
  abort: uncommitted changes
45840
527ce85c2e60 errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 28065
diff changeset
    19
  [20]
17849
6da47b655d97 update: check for missing files with --check (issue3595)
Matt Mackall <mpm@selenic.com>
parents: 14485
diff changeset
    20
  $ hg revert b
28065
6b1fc09c699a update: change default destination to tipmost descendant (issue4673) (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28029
diff changeset
    21
  $ hg update -c 2
12154
c85e07a2d783 test-merge5: ensure updating to tip across branches is tested
Brodie Rao <brodie@bitheap.org>
parents: 11978
diff changeset
    22
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
11978
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
    23
  $ mv a c
415
c2b9502a4e96 [PATCH] Don't prompt user for keep-vs-delete when the merge is about to be aborted
mpm@selenic.com
parents:
diff changeset
    24
12155
94ad12aa0530 test-merge5: removed unnecessary parts of test
Martin Geisler <mg@lazybytes.net>
parents: 12154
diff changeset
    25
Should abort:
94ad12aa0530 test-merge5: removed unnecessary parts of test
Martin Geisler <mg@lazybytes.net>
parents: 12154
diff changeset
    26
23026
fe80fdf68ba7 test-merge5: remove obsolete '-y' and its motivating comment
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 19801
diff changeset
    27
  $ hg update 1
19799
ab3e42225dbc update: add error message for dirty non-linear update with no rev
Siddharth Agarwal <sid0@fb.com>
parents: 19798
diff changeset
    28
  abort: uncommitted changes
ab3e42225dbc update: add error message for dirty non-linear update with no rev
Siddharth Agarwal <sid0@fb.com>
parents: 19798
diff changeset
    29
  (commit or update --clean to discard changes)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12155
diff changeset
    30
  [255]
11978
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
    31
  $ mv c a
12155
94ad12aa0530 test-merge5: removed unnecessary parts of test
Martin Geisler <mg@lazybytes.net>
parents: 12154
diff changeset
    32
94ad12aa0530 test-merge5: removed unnecessary parts of test
Martin Geisler <mg@lazybytes.net>
parents: 12154
diff changeset
    33
Should succeed:
94ad12aa0530 test-merge5: removed unnecessary parts of test
Martin Geisler <mg@lazybytes.net>
parents: 12154
diff changeset
    34
23026
fe80fdf68ba7 test-merge5: remove obsolete '-y' and its motivating comment
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 19801
diff changeset
    35
  $ hg update 1
11978
ef4a1ffbf519 tests: unify test-merge5
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 6350
diff changeset
    36
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved