tests/test-revisions.t
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 46115 be3d8178251e
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:
38842
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     1
  $ hg init repo
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     2
  $ cd repo
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     3
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     4
  $ echo 0 > a
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     5
  $ hg ci -qAm 0
39069
4c4825db29e1 shortest: don't include nullid in disambigution revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38843
diff changeset
     6
  $ for i in 5 8 14 43 167; do
38842
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     7
  >   hg up -q 0
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     8
  >   echo $i > a
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     9
  >   hg ci -qm $i
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    10
  > done
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    11
  $ cat <<EOF >> .hg/hgrc
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    12
  > [alias]
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    13
  > l = log -T '{rev}:{shortest(node,1)}\n'
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    14
  > EOF
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    15
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    16
  $ hg l
39069
4c4825db29e1 shortest: don't include nullid in disambigution revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38843
diff changeset
    17
  5:00f
38842
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    18
  4:7ba5d
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    19
  3:7ba57
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    20
  2:72
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    21
  1:9
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    22
  0:b
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    23
  $ cat <<EOF >> .hg/hgrc
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    24
  > [experimental]
39069
4c4825db29e1 shortest: don't include nullid in disambigution revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38843
diff changeset
    25
  > revisions.disambiguatewithin=not 4
38842
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    26
  > EOF
38843
6f7c9527030b scmutil: make shortest() respect disambiguation revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38842
diff changeset
    27
  $ hg l
40341
d916ed3ca951 revisions: when using prefixhexnode, ensure we prefix "0"
Kyle Lippincott <spectral@google.com>
parents: 39069
diff changeset
    28
  5:00
38843
6f7c9527030b scmutil: make shortest() respect disambiguation revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38842
diff changeset
    29
  4:7ba5d
6f7c9527030b scmutil: make shortest() respect disambiguation revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38842
diff changeset
    30
  3:7b
6f7c9527030b scmutil: make shortest() respect disambiguation revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38842
diff changeset
    31
  2:72
6f7c9527030b scmutil: make shortest() respect disambiguation revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38842
diff changeset
    32
  1:9
6f7c9527030b scmutil: make shortest() respect disambiguation revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38842
diff changeset
    33
  0:b
38842
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    34
9 was unambiguous and still is
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    35
  $ hg l -r 9
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    36
  1:9
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    37
7 was ambiguous and still is
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    38
  $ hg l -r 7
46115
be3d8178251e errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents: 45906
diff changeset
    39
  abort: ambiguous revision identifier: 7
be3d8178251e errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents: 45906
diff changeset
    40
  [10]
38842
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    41
7b is no longer ambiguous
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    42
  $ hg l -r 7b
38843
6f7c9527030b scmutil: make shortest() respect disambiguation revset
Martin von Zweigbergk <martinvonz@google.com>
parents: 38842
diff changeset
    43
  3:7b
38842
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    44
503f936489dd lookup: add option to disambiguate prefix within revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    45
  $ cd ..