tests/test-rebase-detach.t
author Martijn Pieters <mj@zopatista.com>
Tue, 31 Jul 2018 19:37:54 +0200
changeset 38781 0a57945aaf7f
parent 35393 4441705b7111
child 40466 b57f2734ac92
permissions -rw-r--r--
manifest: persist the manifestfulltext cache Reconstructing the manifest from the revlog takes time, so much so that there already is a LRU cache to avoid having to load a manifest multiple times. This patch persists that LRU cache in the .hg/cache directory, so we can re-use this cache across hg commands. Commit benchmark (run on Macos 10.13 on a 2017-model Macbook Pro with Core i7 2.9GHz and flash drive), testing without and with patch run 5 times, baseline is r2a227782e754: * committing to an existing file, against the mozilla-central repository. Baseline real time average 1.9692, with patch 1.3786. A new debugcommand "hg debugmanifestfulltextcache" lets you inspect the cache, clear it, or add specific manifest nodeids to it. When calling repo.updatecaches(), the manifest(s) for the working copy parents are added to the cache. The hg perfmanifest command has an additional --clear-disk switch to clear this cache when testing manifest loading performance. Using this command to test performance on the firefox repository for revision f947d902ed91, whose manifest has a delta chain length of 60540, we see: $ hg perfmanifest f947d902ed91 --clear-disk ! wall 0.972253 comb 0.970000 user 0.850000 sys 0.120000 (best of 10) $ hg debugmanifestfulltextcache -a `hg log --debug -r f947d902ed91 | grep manifest | cut -d: -f3` Cache contains 1 manifest entries, in order of most to least recent: id: 0294517df4aad07c70701db43bc7ff24c3ce7dbc, size 25.6 MB Total cache data size 25.6 MB, on-disk 0 bytes $ hg perfmanifest f947d902ed91 ! wall 0.036748 comb 0.040000 user 0.020000 sys 0.020000 (best of 100) Worst-case scenario: a manifest text loaded from a single delta; in the firefox repository manifest node 9a1246ff762e is the chain base for the manifest attached to revision f947d902ed91. Loading this from a full cache file is just as fast as without the cache; the extra node ids ensure a big full cache: $ for node in 9a1246ff762e 1a1922c14a3e 54a31d11a36a 0294517df4aa; do > hgd debugmanifestfulltextcache -a $node > /dev/null > done $ hgd perfmanifest -m 9a1246ff762e ! wall 0.077513 comb 0.080000 user 0.030000 sys 0.050000 (best of 100) $ hgd perfmanifest -m 9a1246ff762e --clear-disk ! wall 0.078547 comb 0.080000 user 0.070000 sys 0.010000 (best of 100)

  $ 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" (D tip)
  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" (E tip)
  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" (D tip)
  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" (E tip)
  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" (E tip)
  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 "E" (tip)
  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 "J" (tip)
  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:fail
  rebasing 3:17b4880d2402 "B2" (tip)
  merging B
  warning: conflicts while merging B! (edit, then use 'hg resolve --mark')
  unresolved conflicts (see hg resolve, then hg rebase --continue)
  [1]
  $ hg resolve --all -t internal:local
  (no more unresolved files)
  continue: hg rebase --continue
  $ hg rebase -c
  rebasing 3:17b4880d2402 "B2" (tip)
  note: rebase of 3:17b4880d2402 created no changes to commit
  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 ..