tests/test-rebase-detach.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 09 Apr 2024 02:54:19 +0200
changeset 51586 1cef1412af3e
parent 45826 21733e8c924f
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

  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > rebase=
  > 
  > [alias]
  > tglog = log -G --template "{rev}: {node|short} '{desc}'\n"
  > 
  > [extensions]
  > drawdag=$TESTDIR/drawdag.py
  > EOF

Rebasing D onto B detaching from C (one commit):

  $ hg init a1
  $ cd a1

  $ hg debugdrawdag <<EOF
  > D
  > |
  > C B
  > |/
  > A
  > EOF
  $ hg phase --force --secret D

  $ hg rebase -s D -d B
  rebasing 3:e7b3f00ed42e D tip "D"
  saved backup bundle to $TESTTMP/a1/.hg/strip-backup/e7b3f00ed42e-6f368371-rebase.hg

  $ hg log -G --template "{rev}:{phase} '{desc}' {branches}\n"
  o  3:secret 'D'
  |
  | o  2:draft 'C'
  | |
  o |  1:draft 'B'
  |/
  o  0:draft 'A'
  
  $ hg manifest --rev tip
  A
  B
  D

  $ cd ..


Rebasing D onto B detaching from C (two commits):

  $ hg init a2
  $ cd a2

  $ hg debugdrawdag <<EOF
  > E
  > |
  > D
  > |
  > C B
  > |/
  > A
  > EOF

  $ hg rebase -s D -d B
  rebasing 3:e7b3f00ed42e D "D"
  rebasing 4:69a34c08022a E tip "E"
  saved backup bundle to $TESTTMP/a2/.hg/strip-backup/e7b3f00ed42e-a2ec7cea-rebase.hg

  $ hg tglog
  o  4: ee79e0744528 'E'
  |
  o  3: 10530e1d72d9 'D'
  |
  | o  2: dc0947a82db8 'C'
  | |
  o |  1: 112478962961 'B'
  |/
  o  0: 426bada5c675 'A'
  
  $ hg manifest --rev tip
  A
  B
  D
  E

  $ cd ..

Rebasing C onto B using detach (same as not using it):

  $ hg init a3
  $ cd a3

  $ hg debugdrawdag <<EOF
  > D
  > |
  > C B
  > |/
  > A
  > EOF

  $ hg rebase -s C -d B
  rebasing 2:dc0947a82db8 C "C"
  rebasing 3:e7b3f00ed42e D tip "D"
  saved backup bundle to $TESTTMP/a3/.hg/strip-backup/dc0947a82db8-b8481714-rebase.hg

  $ hg tglog
  o  3: 7375f3dbfb0f 'D'
  |
  o  2: bbfdd6cb49aa 'C'
  |
  o  1: 112478962961 'B'
  |
  o  0: 426bada5c675 'A'
  
  $ hg manifest --rev tip
  A
  B
  C
  D

  $ cd ..


Rebasing D onto B detaching from C and collapsing:

  $ hg init a4
  $ cd a4

  $ hg debugdrawdag <<EOF
  > E
  > |
  > D
  > |
  > C B
  > |/
  > A
  > EOF
  $ hg phase --force --secret E

  $ hg rebase --collapse -s D -d B
  rebasing 3:e7b3f00ed42e D "D"
  rebasing 4:69a34c08022a E tip "E"
  saved backup bundle to $TESTTMP/a4/.hg/strip-backup/e7b3f00ed42e-a2ec7cea-rebase.hg

  $ hg  log -G --template "{rev}:{phase} '{desc}' {branches}\n"
  o  3:secret 'Collapsed revision
  |  * D
  |  * E'
  | o  2:draft 'C'
  | |
  o |  1:draft 'B'
  |/
  o  0:draft 'A'
  
  $ hg manifest --rev tip
  A
  B
  D
  E

  $ cd ..

Rebasing across null as ancestor
  $ hg init a5
  $ cd a5

  $ hg debugdrawdag <<EOF
  > E
  > |
  > D
  > |
  > C
  > |
  > A B
  > EOF

  $ hg rebase -s C -d B
  rebasing 2:dc0947a82db8 C "C"
  rebasing 3:e7b3f00ed42e D "D"
  rebasing 4:69a34c08022a E tip "E"
  saved backup bundle to $TESTTMP/a5/.hg/strip-backup/dc0947a82db8-3eefec98-rebase.hg

  $ hg tglog
  o  4: e3d0c70d606d 'E'
  |
  o  3: e9153d36a1af 'D'
  |
  o  2: a7ac28b870a8 'C'
  |
  o  1: fc2b737bb2e5 'B'
  
  o  0: 426bada5c675 'A'
  
  $ hg rebase -d 1 -s 3
  rebasing 3:e9153d36a1af "D"
  rebasing 4:e3d0c70d606d tip "E"
  saved backup bundle to $TESTTMP/a5/.hg/strip-backup/e9153d36a1af-db7388ed-rebase.hg
  $ hg tglog
  o  4: 2c24e540eccd 'E'
  |
  o  3: 73f786ed52ff 'D'
  |
  | o  2: a7ac28b870a8 'C'
  |/
  o  1: fc2b737bb2e5 'B'
  
  o  0: 426bada5c675 'A'
  
  $ cd ..

Verify that target is not selected as external rev (issue3085)

  $ hg init a6
  $ cd a6

  $ hg debugdrawdag <<EOF
  > H
  > | G
  > |/|
  > F E
  > |/
  > A
  > EOF
  $ hg up -q G

  $ echo "I" >> E
  $ hg ci -m "I"
  $ hg tag --local I
  $ hg merge H
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg ci -m "Merge"
  $ echo "J" >> F
  $ hg ci -m "J"
  $ hg tglog
  @  7: c6aaf0d259c0 'J'
  |
  o    6: 0cfbc7e8faaf 'Merge'
  |\
  | o  5: b92d164ad3cb 'I'
  | |
  o |  4: 4ea5b230dea3 'H'
  | |
  | o  3: c6001eacfde5 'G'
  |/|
  o |  2: 8908a377a434 'F'
  | |
  | o  1: 7fb047a69f22 'E'
  |/
  o  0: 426bada5c675 'A'
  
  $ hg rebase -s I -d H --collapse --config ui.merge=internal:other
  rebasing 5:b92d164ad3cb I "I"
  rebasing 6:0cfbc7e8faaf "Merge"
  rebasing 7:c6aaf0d259c0 tip "J"
  saved backup bundle to $TESTTMP/a6/.hg/strip-backup/b92d164ad3cb-88fd7ab7-rebase.hg

  $ hg tglog
  @  5: 65079693dac4 'Collapsed revision
  |  * I
  |  * Merge
  |  * J'
  o  4: 4ea5b230dea3 'H'
  |
  | o  3: c6001eacfde5 'G'
  |/|
  o |  2: 8908a377a434 'F'
  | |
  | o  1: 7fb047a69f22 'E'
  |/
  o  0: 426bada5c675 'A'
  

  $ hg log --rev tip
  changeset:   5:65079693dac4
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     Collapsed revision
  

  $ cd ..

Ensure --continue restores a correct state (issue3046) and phase:
  $ hg init a7
  $ cd a7

  $ hg debugdrawdag <<EOF
  > C B
  > |/
  > A
  > EOF
  $ hg up -q C
  $ echo 'B2' > B
  $ hg ci -A -m 'B2'
  adding B
  $ hg phase --force --secret .
  $ hg rebase -s . -d B --config ui.merge=internal:merge
  rebasing 3:17b4880d2402 tip "B2"
  merging B
  warning: conflicts while merging B! (edit, then use 'hg resolve --mark')
  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
  [240]
  $ hg resolve --all -t internal:local
  (no more unresolved files)
  continue: hg rebase --continue
  $ hg rebase -c
  rebasing 3:17b4880d2402 tip "B2"
  note: not rebasing 3:17b4880d2402 tip "B2", its destination already has all its changes
  saved backup bundle to $TESTTMP/a7/.hg/strip-backup/17b4880d2402-1ae1f6cc-rebase.hg
  $ hg  log -G --template "{rev}:{phase} '{desc}' {branches}\n"
  o  2:draft 'C'
  |
  | @  1:draft 'B'
  |/
  o  0:draft 'A'
  

  $ cd ..