tests/svn/svndump-empty.sh
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 16466 c53a49c345e1
permissions -rwxr-xr-x
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:
16466
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     1
#!/bin/sh
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     2
#
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     3
# Use this script to generate empty.svndump
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     4
#
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     5
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     6
mkdir temp
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     7
cd temp
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     8
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     9
mkdir project-orig
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    10
cd project-orig
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    11
mkdir trunk
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    12
mkdir branches
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    13
mkdir tags
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    14
cd ..
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    15
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    16
svnadmin create svn-repo
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    17
svnurl=file://`pwd`/svn-repo
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    18
svn import project-orig $svnurl -m "init projA"
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    19
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    20
svn co $svnurl project
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    21
cd project
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    22
mkdir trunk/dir
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    23
echo a > trunk/dir/a
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    24
svn add trunk/dir
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    25
svn ci -m adddir
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    26
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    27
echo b > trunk/b
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    28
svn add trunk/b
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    29
svn ci -m addb
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    30
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    31
echo c > c
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    32
svn add c
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    33
svn ci -m addc
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    34
cd ..
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    35
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    36
# svnsync repo/trunk/dir only so the last two revisions are empty
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    37
svnadmin create svn-empty
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    38
cat > svn-empty/hooks/pre-revprop-change <<EOF
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    39
#!/bin/sh
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    40
exit 0
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    41
EOF
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    42
chmod +x svn-empty/hooks/pre-revprop-change
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    43
svnsync init --username svnsync file://`pwd`/svn-empty file://`pwd`/svn-repo/trunk/dir
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    44
svnsync sync file://`pwd`/svn-empty
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    45
svn log -v file://`pwd`/svn-empty
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    46
c53a49c345e1 convert/svn: do not try converting empty head revisions (issue3347)
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    47
svnadmin dump svn-empty > ../empty.svndump