tests/test-mq-pull-from-bundle.t
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 39480 89630d0b3e23
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.

#require repobundlerepo

  $ cat <<EOF >> $HGRCPATH
  > [extensions]
  > mq=
  > [alias]
  > tlog = log --template "{rev}: {node|short} {desc}\\n"
  > theads = heads --template "{rev}: {desc}\\n"
  > tincoming = incoming --template "{rev}: {desc}\\n"
  > EOF

Setup main:

  $ hg init base
  $ cd base
  $ echo "One" > one
  $ hg add
  adding one
  $ hg ci -m "main: one added"
  $ echo "++" >> one
  $ hg ci -m "main: one updated"

Bundle main:

  $ hg bundle --base=null ../main.hg
  2 changesets found

  $ cd ..

Incoming to fresh repo:

  $ hg init fresh

  $ hg -R fresh tincoming main.hg
  comparing with main.hg
  0: main: one added
  1: main: one updated
  $ test -f ./fresh/.hg/hg-bundle* && echo 'temp. bundle file remained' || true

  $ hg -R fresh tincoming bundle:fresh+main.hg
  comparing with bundle:fresh+main.hg
  0: main: one added
  1: main: one updated


Setup queue:

  $ cd base
  $ hg qinit -c
  $ hg qnew -m "patch: two added" two.patch
  $ echo two > two
  $ hg add
  adding two
  $ hg qrefresh
  $ hg qcommit -m "queue: two.patch added"
  $ hg qpop -a
  popping two.patch
  patch queue now empty

Bundle queue:

  $ hg -R .hg/patches bundle --base=null ../queue.hgq
  1 changesets found
  $ test -f ./fresh/.hg/hg-bundle* && echo 'temp. bundle file remained' || true

  $ cd ..


Clone base:

  $ hg clone base copy
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd copy
  $ hg qinit -c

Incoming queue bundle:

  $ hg -R .hg/patches tincoming ../queue.hgq
  comparing with ../queue.hgq
  0: queue: two.patch added
  $ test -f .hg/hg-bundle* && echo 'temp. bundle file remained' || true

Pull queue bundle:

  $ hg -R .hg/patches pull --update ../queue.hgq
  pulling from ../queue.hgq
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 3 changes to 3 files
  new changesets d7553909353d (1 drafts)
  merging series
  2 files updated, 1 files merged, 0 files removed, 0 files unresolved
  $ test -f .hg/patches/hg-bundle* && echo 'temp. bundle file remained' || true

  $ hg -R .hg/patches theads
  0: queue: two.patch added

  $ hg -R .hg/patches tlog
  0: d7553909353d queue: two.patch added

  $ hg qseries
  two.patch

  $ cd ..


Clone base again:

  $ hg clone base copy2
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd copy2
  $ hg qinit -c

Unbundle queue bundle:

  $ hg -R .hg/patches unbundle --update ../queue.hgq
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 3 changes to 3 files
  new changesets d7553909353d (1 drafts)
  merging series
  2 files updated, 1 files merged, 0 files removed, 0 files unresolved

  $ hg -R .hg/patches theads
  0: queue: two.patch added

  $ hg -R .hg/patches tlog
  0: d7553909353d queue: two.patch added

  $ hg qseries
  two.patch

  $ cd ..