tests/test-hgweb-bundle.t
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 37422 9fa4a1fdba15
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:
37422
9fa4a1fdba15 tests: skip test-hgweb-bundle.t if we don't support bundlerepos
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35393
diff changeset
     1
#require serve repobundlerepo
22223
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
  $ hg init server
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
  $ cd server
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
  $ cat >> .hg/hgrc << EOF
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
  > [extensions]
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
  > strip=
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
  > EOF
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
  $ echo 1 > foo
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
  $ hg commit -A -m 'first'
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
  adding foo
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
  $ echo 2 > bar
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
  $ hg commit -A -m 'second'
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
  adding bar
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
Produce a bundle to use
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    19
  $ hg strip -r 1
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    20
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
35393
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 25472
diff changeset
    21
  saved backup bundle to $TESTTMP/server/.hg/strip-backup/ed602e697e0f-cc9fff6a-backup.hg
22223
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    22
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    23
Serve from a bundle file
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    24
23835
aa4a1672583e bundles: do not overwrite existing backup bundles (BC)
Durham Goode <durham@fb.com>
parents: 22223
diff changeset
    25
  $ hg serve -R .hg/strip-backup/ed602e697e0f-cc9fff6a-backup.hg -d -p $HGPORT --pid-file=hg.pid
22223
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
  $ cat hg.pid >> $DAEMON_PIDS
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    27
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    28
Ensure we're serving from the bundle
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
25472
4d2b9b304ad0 tests: drop explicit $TESTDIR from executables
Matt Mackall <mpm@selenic.com>
parents: 23835
diff changeset
    30
  $ (get-with-headers.py localhost:$HGPORT 'file/tip/?style=raw')
22223
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    31
  200 Script output follows
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    32
  
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
  
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
  -rw-r--r-- 2 bar
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
  -rw-r--r-- 2 foo
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
  
c39d404f0eb0 hgweb: refresh repository using URL not path (issue4323)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37