tests/test-mq-merge.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 09 Apr 2024 02:54:19 +0200
changeset 51586 1cef1412af3e
parent 44435 4152183acedd
permissions -rw-r--r--
phases: rework the logic of _pushdiscoveryphase to bound complexity This rework the various graph traversal in _pushdiscoveryphase to keep the complexity in check. This is done though a couple of things: - first, limiting the space we have to explore, for example, if we are not in publishing push, we don't need to consider remote draft roots that are also draft locally, as there is nothing to be moved there. - avoid unbounded descendant computation, and use the faster "rev between" computation. This provide a massive boost to performance when exchanging with repository with a massive amount of draft, like mozilla-try: ### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog # benchmark.name = hg.command.push # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.reuse-external-delta-parent = default ## benchmark.variants.revs = any-1-extra-rev before: 20.346590 seconds after: 11.232059 seconds (-38.15%, -7.48 seconds) ## benchmark.variants.revs = any-100-extra-rev before: 24.752051 seconds after: 15.367412 seconds (-37.91%, -9.38 seconds) After this changes, the push operation is still quite too slow. Some of this can be attributed to general phases slowness (reading all the roots from disk for example) and other know slowness (not using persistent-nodemap, branchmap, tags, etc. We are also working on them, but with this series, phase discovery during push no longer showing up in profile and this is a pretty nice and bit low-hanging fruit out of the way. ### (same case as the above) # benchmark.variants.revs = any-1-extra-rev pre-%ln-change: 44.235070 this-changeset: 11.232059 seconds (-74.61%, -33.00 seconds) # benchmark.variants.revs = any-100-extra-rev pre-%ln-change: 49.234697 this-changeset: 15.367412 seconds (-68.79%, -33.87 seconds) Note that with this change, the `hg push` performance is now much closer to the `hg pull` performance, even it still lagging behind a bit. (and the overall performance are still too slow). ### data-env-vars.name = mozilla-try-2023-03-22-ds2-pnm # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.pulled-delta-reuse-policy = default # bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 6.517450 hg.command.push: 11.219888 ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 10.160991 hg.command.push: 14.251107 ### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog # bin-env-vars.hg.py-re2-module = default # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.pulled-delta-reuse-policy = default ## bin-env-vars.hg.flavor = default ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 8.577772 hg.command.push: 11.232059 ## bin-env-vars.hg.flavor = default ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 13.152976 hg.command.push: 15.367412 ## bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 8.731982 hg.command.push: 11.178751 ## bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 13.184236 hg.command.push: 15.620843

Setup extension:

  $ cat <<EOF >> $HGRCPATH
  > [extensions]
  > mq =
  > [mq]
  > git = keep
  > EOF

Test merge with mq changeset as the second parent:

  $ hg init m
  $ cd m
  $ touch a b c
  $ hg add a
  $ hg commit -m a
  $ hg add b
  $ hg qnew -d "0 0" b
  $ hg update 0
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hg add c
  $ hg commit -m c
  created new head
  $ hg merge
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg commit -m merge
  abort: cannot commit over an applied mq patch
  [255]
  $ cd ..

Issue529: mq aborts when merging patch deleting files

  $ checkundo()
  > {
  >     if [ -f .hg/store/undo ]; then
  >         echo ".hg/store/undo still exists"
  >     fi
  > }

Commit two dummy files in "init" changeset:

  $ hg init t
  $ cd t
  $ echo a > a
  $ echo b > b
  $ hg ci -Am init
  adding a
  adding b
  $ hg tag -l init

Create a patch removing a:

  $ hg qnew rm_a
  $ hg rm a
  $ hg qrefresh -m "rm a"

Save the patch queue so we can merge it later:

  $ hg qsave -c -e
  copy $TESTTMP/t/.hg/patches to $TESTTMP/t/.hg/patches.1
  $ checkundo

Update b and commit in an "update" changeset:

  $ hg up -C init
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo b >> b
  $ hg st
  M b
  $ hg ci -m update
  created new head

# Here, qpush used to abort with :
# The system cannot find the file specified => a
  $ hg manifest
  a
  b

  $ hg qpush -a -m
  merging with queue at: $TESTTMP/t/.hg/patches.1
  applying rm_a
  now at: rm_a

  $ checkundo
  $ hg manifest
  b

Ensure status is correct after merge:

  $ hg qpop -a
  popping rm_a
  popping .hg.patches.merge.marker
  patch queue now empty

  $ cd ..

Classic MQ merge sequence *with an explicit named queue*:

  $ hg init t2
  $ cd t2
  $ echo '[diff]' > .hg/hgrc
  $ echo 'nodates = 1' >> .hg/hgrc
  $ echo a > a
  $ hg ci -Am init
  adding a
  $ echo b > a
  $ hg ci -m changea
  $ hg up -C 0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg cp a aa
  $ echo c >> a
  $ hg qnew --git -f -e patcha
  $ echo d >> a
  $ hg qnew -d '0 0' -f -e patcha2

Create the reference queue:

  $ hg qsave -c -e -n refqueue
  copy $TESTTMP/t2/.hg/patches to $TESTTMP/t2/.hg/refqueue
  $ hg up -C 1
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved

Merge:

  $ HGMERGE=internal:other hg qpush -a -m -n refqueue
  merging with queue at: $TESTTMP/t2/.hg/refqueue
  applying patcha
  patching file a
  Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines).
  fuzz found when applying patch, stopping
  patch didn't work out, merging patcha
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  0 files updated, 2 files merged, 0 files removed, 0 files unresolved
  applying patcha2
  now at: patcha2

Check patcha is still a git patch:

  $ cat .hg/patches/patcha
  # HG changeset patch
  # Parent  d3873e73d99ef67873dac33fbcc66268d5d2b6f4
  
  diff --git a/a b/a
  --- a/a
  +++ b/a
  @@ -1,1 +1,2 @@
  -b
  +a
  +c
  diff --git a/a b/aa
  copy from a
  copy to aa
  --- a/a
  +++ b/aa
  @@ -1,1 +1,1 @@
  -b
  +a

Check patcha2 is still a regular patch:

  $ cat .hg/patches/patcha2
  # HG changeset patch
  # Date 0 0
  # Parent  ???????????????????????????????????????? (glob)
  
  diff -r ???????????? -r ???????????? a (glob)
  --- a/a
  +++ b/a
  @@ -1,2 +1,3 @@
   a
   c
  +d

  $ cd ..