tests/test-convert-bzr-ghosts.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:
26066
89872688893f tests: move '#require bzr' into .t files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 16913
diff changeset
     1
#require bzr
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
     2
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
     3
  $ . "$TESTDIR/bzr-definitions"
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
     4
  $ cat > ghostcreator.py <<EOF
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
     5
  > import sys
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 39707
diff changeset
     6
  > from breezy import workingtree
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 39707
diff changeset
     7
  > import breezy.bzr.bzrdir
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
     8
  > wt = workingtree.WorkingTree.open('.')
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
     9
  > 
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    10
  > message, ghostrev = sys.argv[1:]
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 39707
diff changeset
    11
  > wt.set_parent_ids(wt.get_parent_ids() + [ghostrev.encode()])
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    12
  > wt.commit(message)
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    13
  > EOF
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    14
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    15
ghost revisions
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    16
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    17
  $ mkdir test-ghost-revisions
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    18
  $ cd test-ghost-revisions
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 39707
diff changeset
    19
  $ brz init -q source
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    20
  $ cd source
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    21
  $ echo content > somefile
47377
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 39707
diff changeset
    22
  $ brz add -q somefile
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Raphaël Gomès <rgomes@octobus.net>
parents: 39707
diff changeset
    23
  $ brz commit -q -m 'Initial layout setup'
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    24
  $ echo morecontent >> somefile
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39222
diff changeset
    25
  $ "$PYTHON" ../../ghostcreator.py 'Commit with ghost revision' ghostrev
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    26
  $ cd ..
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    27
  $ hg convert source source-hg
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    28
  initializing destination source-hg repository
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    29
  scanning source...
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    30
  sorting...
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    31
  converting...
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    32
  1 Initial layout setup
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    33
  0 Commit with ghost revision
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    34
  $ glog -R source-hg
39222
7a88643bc0ef tests: show added/modified/removed files when logging repos converted from bzr
Matt Harbison <matt_harbison@yahoo.com>
parents: 32940
diff changeset
    35
  o  1@source "Commit with ghost revision" files+: [], files-: [], files: [somefile]
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    36
  |
39222
7a88643bc0ef tests: show added/modified/removed files when logging repos converted from bzr
Matt Harbison <matt_harbison@yahoo.com>
parents: 32940
diff changeset
    37
  o  0@source "Initial layout setup" files+: [somefile], files-: [], files: []
12515
b6a784e39ad4 tests: unify test-convert-bzr-ghosts
Matt Mackall <mpm@selenic.com>
parents: 7058
diff changeset
    38
  
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16060
diff changeset
    39
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16060
diff changeset
    40
  $ cd ..