tests/test-convert-bzr-114.t
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 47377 26127236b229
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:
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 26066
diff changeset
     1
#require bzr
12513
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
     2
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
     3
  $ . "$TESTDIR/bzr-definitions"
8126
13b36eb14324 convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     4
12513
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
     5
The file/directory replacement can only be reproduced on
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
     6
bzr >= 1.4. Merge it back in test-convert-bzr-directories once
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
     7
this version becomes mainstream.
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
     8
replace file with dir
8126
13b36eb14324 convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     9
12513
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    10
  $ mkdir test-replace-file-with-dir
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    11
  $ cd test-replace-file-with-dir
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 26066
diff changeset
    12
  $ brz init -q source
12513
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    13
  $ cd source
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    14
  $ echo d > d
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 26066
diff changeset
    15
  $ brz add -q d
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 26066
diff changeset
    16
  $ brz commit -q -m 'add d file'
12513
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    17
  $ rm d
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    18
  $ mkdir d
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 26066
diff changeset
    19
  $ brz add -q d
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 26066
diff changeset
    20
  $ brz commit -q -m 'replace with d dir'
12513
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    21
  $ echo a > d/a
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 26066
diff changeset
    22
  $ brz add -q d/a
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 26066
diff changeset
    23
  $ brz commit -q -m 'add d/a'
12513
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    24
  $ cd ..
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    25
  $ hg convert source source-hg
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    26
  initializing destination source-hg repository
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    27
  scanning source...
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    28
  sorting...
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    29
  converting...
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    30
  2 add d file
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    31
  1 replace with d dir
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    32
  0 add d/a
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    33
  $ manifest source-hg tip
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    34
  % manifest of tip
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    35
  644   d/a
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    36
  $ cd source-hg
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    37
  $ hg update
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    38
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
d1f88ae495b4 tests: unify test-convert-bzr-114
Matt Mackall <mpm@selenic.com>
parents: 8126
diff changeset
    39
  $ cd ../..