tests/bundles/test-revlog-diff-relative-to-nullrev.sh
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 49239 a94f28be2e6e
child 51046 f636103c4d67
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:
49209
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
     1
#!/bin/bash
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
     2
#
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
     3
# Make sure to patch mercurial to create the delta against nullrev
49237
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
     4
#
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
     5
# # Parent  cdb85d0512b81031d4a7b30d6a5ddbe69ef1a876
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
     6
#
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
     7
# diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
     8
# --- a/mercurial/revlogutils/deltas.py
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
     9
# +++ b/mercurial/revlogutils/deltas.py
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    10
# @@ -1117,7 +1117,10 @@ class deltacomputer:
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    11
#                  candidaterevs = next(groups)
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    12
#
49209
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    13
#          if deltainfo is None:
49237
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    14
# -            deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev)
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    15
# +            if revlog._generaldelta:
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    16
# +                deltainfo = self._builddeltainfo(revinfo, nullrev, fh)
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    17
# +            else:
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    18
# +                deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev)
996a70c75c66 test-revlog: update the patch used to test delta againts nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49209
diff changeset
    19
49209
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    20
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    21
cd "`dirname \"$0\"`"
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    22
export HGRCPATH=
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    23
export HGMODULEPOLICY=py
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    24
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    25
rm -rf nullrev-diff
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    26
../../hg init nullrev-diff  --config format.revlog-compression=zlib
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    27
cd nullrev-diff
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    28
echo hi > a
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    29
../../../hg commit -Am root-B
49238
6aae0e1ecdbc test-revlog: adds a non-root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49237
diff changeset
    30
echo ho > a
6aae0e1ecdbc test-revlog: adds a non-root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49237
diff changeset
    31
../../../hg commit -Am child-A
49239
a94f28be2e6e test-revlog: adds a new root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49238
diff changeset
    32
hg up null
a94f28be2e6e test-revlog: adds a new root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49238
diff changeset
    33
echo ha > a
a94f28be2e6e test-revlog: adds a new root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49238
diff changeset
    34
../../../hg commit -Am root-A
49209
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    35
../../../hg debugdeltachain a
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    36
rm -rf .hg/cache/ .hg/wcache/
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    37
cd ..
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    38
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    39
tar cf test-revlog-diff-relative-to-nullrev.tar nullrev-diff
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    40
2dd53a33aefa test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff changeset
    41
rm -rf nullrev-diff