tests/test-mq-qrefresh.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sat, 13 Apr 2024 23:40:28 +0200
changeset 51592 24844407fa0d
parent 46116 17a695357270
permissions -rw-r--r--
perf: clear vfs audit_cache before each run When generating a stream clone, we spend a large amount of time auditing path. Before this changes, the first run was warming the vfs cache for the other runs, leading to a large runtime difference and a "faulty" reported timing for the operation. We now clear this important cache between run to get a more realistic timing. Below are some example of median time change when clearing these cases. The maximum time for a run did not changed significantly. ### data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog # benchmark.name = hg.perf.exchange.stream.generate # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.version = latest no-clearing: 17.289905 cache-clearing: 21.587965 (+24.86%, +4.30) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog no-clearing: 32.670748 cache-clearing: 40.467095 (+23.86%, +7.80) ## data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog no-clearing: 37.838858 cache-clearing: 46.072749 (+21.76%, +8.23) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog no-clearing: 32.969395 cache-clearing: 39.646209 (+20.25%, +6.68) In addition, this significantly reduce the timing difference between the performance command, from the perf extensions and a `real `hg bundle` call producing a stream bundle. Some significant differences remain especially on the "mozilla-try" repositories, but they are now smaller. Note that some of that difference will actually not be attributable to the stream generation (like maybe phases or branch map computation). Below are some benchmarks done on a currently draft changeset fixing some unrelated slowness in `hg bundle` (34a78972af409d1ff37c29e60f6ca811ad1a457d) ### data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default hg.perf.exchange.stream.generate: 21.587965 hg.command.bundle: 24.301799 (+12.57%, +2.71) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 40.467095 hg.command.bundle: 44.831317 (+10.78%, +4.36) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 39.646209 hg.command.bundle: 45.395258 (+14.50%, +5.75) ## data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog hg.perf.exchange.stream.generate: 46.072749 hg.command.bundle: 55.882608 (+21.29%, +9.81) ## data-env-vars.name = mozilla-try-2023-03-22-zlib-general-delta hg.perf.exchange.stream.generate: 334.716708 hg.command.bundle: 377.856767 (+12.89%, +43.14) ## data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 302.972301 hg.command.bundle: 326.098755 (+7.63%, +23.13)

  $ cat <<EOF >> $HGRCPATH
  > [extensions]
  > mq =
  > [diff]
  > nodates = 1
  > EOF

  $ hg init a
  $ cd a

  $ mkdir 1 2
  $ echo 'base' > 1/base
  $ echo 'base' > 2/base
  $ hg ci -Ambase
  adding 1/base
  adding 2/base

  $ hg qnew -mmqbase mqbase

  $ echo 'patched' > 1/base
  $ echo 'patched' > 2/base
  $ hg qrefresh

  $ hg qdiff
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ hg qdiff .
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ echo 'patched again' > base
  $ hg qrefresh 1

  $ hg qdiff
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ hg qdiff .
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched

qrefresh . in subdir:

  $ ( cd 1 ; hg qrefresh . )

  $ hg qdiff
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ hg qdiff .
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched

qrefresh in hg-root again:

  $ hg qrefresh

  $ hg qdiff
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ hg qdiff .
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched


qrefresh --short tests:

  $ echo 'orphan' > orphanchild
  $ hg add orphanchild
  $ hg qrefresh nonexistentfilename # clear patch
  nonexistentfilename: * (glob)
  $ hg diff -c qtip
  $ hg qrefresh --short 1/base
  $ hg qrefresh --short 2/base

  $ hg qdiff
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 orphanchild
  --- /dev/null
  +++ b/orphanchild
  @@ -0,0 +1,1 @@
  +orphan

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ hg st
  A orphanchild
  ? base

diff shows what is not in patch:

  $ hg diff
  diff -r ???????????? orphanchild (glob)
  --- /dev/null
  +++ b/orphanchild
  @@ -0,0 +1,1 @@
  +orphan

Before starting exclusive tests:

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

Exclude 2/base:

  $ hg qref -s -X 2/base

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched

status shows 2/base as dirty:

  $ hg status
  M 2/base
  A orphanchild
  ? base

Remove 1/base and add 2/base again but not orphanchild:

  $ hg qref -s -X orphanchild -X 1/base 2/base orphanchild

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 2/base
  --- a/2/base
  +++ b/2/base
  @@ -1,1 +1,1 @@
  -base
  +patched

Add 1/base with include filter - and thus remove 2/base from patch:

  $ hg qref -s -I 1/ o* */*

  $ cat .hg/patches/mqbase
  # HG changeset patch
  # Parent  e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
  mqbase
  
  diff -r e7af5904b465 1/base
  --- a/1/base
  +++ b/1/base
  @@ -1,1 +1,1 @@
  -base
  +patched

  $ cd ..


Test qrefresh --git losing copy metadata:

  $ hg init repo
  $ cd repo

  $ echo "[diff]" >> .hg/hgrc
  $ echo "git=True" >> .hg/hgrc
  $ echo a > a

  $ hg ci -Am adda
  adding a
  $ hg copy a ab
  $ echo b >> ab
  $ hg copy a ac
  $ echo c >> ac

Capture changes:

  $ hg qnew -f p1

  $ hg qdiff
  diff --git a/a b/ab
  copy from a
  copy to ab
  --- a/a
  +++ b/ab
  @@ -1,1 +1,2 @@
   a
  +b
  diff --git a/a b/ac
  copy from a
  copy to ac
  --- a/a
  +++ b/ac
  @@ -1,1 +1,2 @@
   a
  +c

Refresh and check changes again:

  $ hg qrefresh

  $ hg qdiff
  diff --git a/a b/ab
  copy from a
  copy to ab
  --- a/a
  +++ b/ab
  @@ -1,1 +1,2 @@
   a
  +b
  diff --git a/a b/ac
  copy from a
  copy to ac
  --- a/a
  +++ b/ac
  @@ -1,1 +1,2 @@
   a
  +c

  $ cd ..


Issue1441: qrefresh confused after hg rename:

  $ hg init repo-1441
  $ cd repo-1441
  $ echo a > a
  $ hg add a
  $ hg qnew -f p
  $ hg mv a b
  $ hg qrefresh

  $ hg qdiff
  diff -r 000000000000 b
  --- /dev/null
  +++ b/b
  @@ -0,0 +1,1 @@
  +a

  $ cd ..


Issue2025: qrefresh does not honor filtering options when tip !=
qtip:

  $ hg init repo-2025
  $ cd repo-2025
  $ echo a > a
  $ echo b > b
  $ hg ci -qAm addab
  $ echo a >> a
  $ echo b >> b
  $ hg qnew -f patch
  $ hg up -qC 0
  $ echo c > c
  $ hg ci -qAm addc
  $ hg up -qC 1

refresh with tip != qtip:

  $ hg --config diff.nodates=1 qrefresh -I b

  $ hg st
  M a

  $ cat b
  b
  b

  $ cat .hg/patches/patch
  # HG changeset patch
  # Parent  1a60229be7ac3e4a7f647508e99b87bef1f03593
  
  diff -r 1a60229be7ac b
  --- a/b
  +++ b/b
  @@ -1,1 +1,2 @@
   b
  +b

  $ cd ..


Issue1441 with git patches:

  $ hg init repo-1441-git
  $ cd repo-1441-git

  $ echo "[diff]" >> .hg/hgrc
  $ echo "git=True" >> .hg/hgrc

  $ echo a > a
  $ hg add a
  $ hg qnew -f p
  $ hg mv a b
  $ hg qrefresh

  $ hg qdiff --nodates
  diff --git a/b b/b
  new file mode 100644
  --- /dev/null
  +++ b/b
  @@ -0,0 +1,1 @@
  +a

  $ cd ..

Refresh with bad usernames. Mercurial used to abort on bad usernames,
but only after writing the bad name into the patch.

  $ hg init bad-usernames
  $ cd bad-usernames
  $ touch a
  $ hg add a
  $ hg qnew a
  $ hg qrefresh -u 'foo
  > bar'
  transaction abort!
  rollback completed
  qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
  abort: username 'foo\nbar' contains a newline
  [50]
  $ rm a
  $ cat .hg/patches/a
  # HG changeset patch
  # Parent  0000000000000000000000000000000000000000
  
  diff --git a/a b/a
  new file mode 100644
  $ hg qpush
  applying a
  now at: a
  $ hg qrefresh -u ' '
  transaction abort!
  rollback completed
  qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
  abort: empty username
  [50]
  $ cat .hg/patches/a
  # HG changeset patch
  # Parent  0000000000000000000000000000000000000000
  
  diff --git a/a b/a
  new file mode 100644
  $ cd ..

Refresh with phase data:



  $ cd repo
  $ echo 'babar' >> a
  $ hg qnew -m 'update a' p2.diff
  $ hg phase p2.diff
  2: draft
  $ echo 'beber' >> a
  $ hg qref
  $ hg phase p2.diff
  2: draft
  $ hg phase --force --secret p2.diff
  $ echo 'bibir' >> a
  $ hg qref
  $ hg phase p2.diff
  2: secret

  $ cd ..