Skip to content
Snippets Groups Projects
test-upgrade-repo.t 81.7 KiB
Newer Older
  $ cat >> $HGRCPATH << EOF
  > [extensions]
  > share =
  > [format]
  > # stabilize test accross variant
  > revlog-compression=zlib
  > [storage]
  > dirstate-v2.slow-path=allow
  > EOF

store and revlogv1 are required in source

  $ hg --config format.usestore=false init no-store
  $ hg -R no-store debugupgraderepo
  abort: cannot upgrade repository; requirement missing: store
  [255]

  $ hg init no-revlogv1
  $ cat > no-revlogv1/.hg/requires << EOF
  > dotencode
  > fncache
  > generaldelta
  > store
  > EOF

  $ hg -R no-revlogv1 debugupgraderepo
  abort: cannot upgrade repository; missing a revlog version

Cannot upgrade shared repositories

  $ hg init share-parent
  $ hg -R share-parent debugbuilddag -n .+9
  $ hg -R share-parent up tip
  10 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg -q share share-parent share-child

  $ hg -R share-child debugupgraderepo --config format.sparse-revlog=no
  abort: cannot use these actions on a share repository: sparserevlog
  (upgrade the main repository directly)
Unless the action is compatible with share

  $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=yes --quiet
  requirements
     preserved: * (glob)
     added: dirstate-v2
  
  no revlogs to process
  

  $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=yes --quiet --run
  upgrade will perform the following actions:
  
  requirements
     preserved: * (glob)
     added: dirstate-v2
  
  no revlogs to process
  
  $ hg debugformat -R share-child dirstate-v2
  format-variant     repo
  $ hg debugformat -R share-parent dirstate-v2
  format-variant     repo
  dirstate-v2:         no
  $ hg status --all -R share-child
  C nf0
  C nf1
  C nf2
  C nf3
  C nf4
  C nf5
  C nf6
  C nf7
  C nf8
  C nf9
  $ hg log -l 3 -R share-child
  changeset:   9:0059eb38e4a4
  tag:         tip
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:09 1970 +0000
  summary:     r9
  
  changeset:   8:4d5be70c8130
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:08 1970 +0000
  summary:     r8
  
  changeset:   7:e60bfe72517e
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:07 1970 +0000
  summary:     r7
  
  $ hg status --all -R share-parent
  C nf0
  C nf1
  C nf2
  C nf3
  C nf4
  C nf5
  C nf6
  C nf7
  C nf8
  C nf9
  $ hg log -l 3 -R share-parent
  changeset:   9:0059eb38e4a4
  tag:         tip
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:09 1970 +0000
  summary:     r9
  
  changeset:   8:4d5be70c8130
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:08 1970 +0000
  summary:     r8
  
  changeset:   7:e60bfe72517e
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:07 1970 +0000
  summary:     r7
  

  $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=no --quiet --run
  upgrade will perform the following actions:
  
  requirements
     preserved: * (glob)
     removed: dirstate-v2
  
  no revlogs to process
  
  $ hg debugformat -R share-child dirstate-v2
  format-variant     repo
  $ hg debugformat -R share-parent dirstate-v2
  format-variant     repo
  dirstate-v2:         no
  $ hg status --all -R share-child
  C nf0
  C nf1
  C nf2
  C nf3
  C nf4
  C nf5
  C nf6
  C nf7
  C nf8
  C nf9
  $ hg log -l 3 -R share-child
  changeset:   9:0059eb38e4a4
  tag:         tip
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:09 1970 +0000
  summary:     r9
  
  changeset:   8:4d5be70c8130
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:08 1970 +0000
  summary:     r8
  
  changeset:   7:e60bfe72517e
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:07 1970 +0000
  summary:     r7
  
  $ hg status --all -R share-parent
  C nf0
  C nf1
  C nf2
  C nf3
  C nf4
  C nf5
  C nf6
  C nf7
  C nf8
  C nf9
  $ hg log -l 3 -R share-parent
  changeset:   9:0059eb38e4a4
  tag:         tip
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:09 1970 +0000
  summary:     r9
  
  changeset:   8:4d5be70c8130
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:08 1970 +0000
  summary:     r8
  
  changeset:   7:e60bfe72517e
  user:        debugbuilddag
  date:        Thu Jan 01 00:00:07 1970 +0000
  summary:     r7
  
Do not yet support downgrading treemanifest repos

  $ hg --config experimental.treemanifest=true init treemanifest
  $ hg -R treemanifest debugupgraderepo
  abort: cannot upgrade repository; requirement would be removed: treemanifest
Cannot add treemanifest requirement during upgrade

  $ hg init disallowaddedreq
  $ hg -R disallowaddedreq --config experimental.treemanifest=true debugupgraderepo
  abort: cannot upgrade repository; do not support adding requirement: treemanifest

An upgrade of a repository created with recommended settings only suggests optimizations

  $ hg init empty
  $ cd empty
  $ hg debugformat
  share-safe:         yes
  persistent-nodemap:  no (no-rust !)
  persistent-nodemap: yes (rust !)
  revlog-v2:           no
  plain-cl-delta:     yes
  compression:        zlib
  compression-level:  default
  $ hg debugformat --verbose
  format-variant     repo config default
  fncache:            yes    yes     yes
  dotencode:          yes    yes     yes
  generaldelta:       yes    yes     yes
  share-safe:         yes    yes     yes
  persistent-nodemap:  no     no      no (no-rust !)
  persistent-nodemap: yes    yes      no (rust !)
  revlog-v2:           no     no      no
  changelog-v2:        no     no      no
  compression:        zlib   zlib    zlib (no-zstd !)
  compression:        zlib   zlib    zstd (zstd !)
  compression-level:  default default default
  $ hg debugformat --verbose --config format.usefncache=no
  format-variant     repo config default
  fncache:            yes     no     yes
  dotencode:          yes     no     yes
  generaldelta:       yes    yes     yes
  share-safe:         yes    yes     yes
  persistent-nodemap:  no     no      no (no-rust !)
  persistent-nodemap: yes    yes      no (rust !)
  revlog-v2:           no     no      no
  changelog-v2:        no     no      no
  compression:        zlib   zlib    zlib (no-zstd !)
  compression:        zlib   zlib    zstd (zstd !)
  compression-level:  default default default
  $ hg debugformat --verbose --config format.usefncache=no --color=debug
  format-variant     repo config default
  [formatvariant.name.mismatchconfig|fncache:           ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special|     no][formatvariant.default|     yes]
  [formatvariant.name.uptodate|dirstate-v2:       ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.uptodate|tracked-hint:      ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.mismatchconfig|dotencode:         ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special|     no][formatvariant.default|     yes]
  [formatvariant.name.uptodate|generaldelta:      ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
  [formatvariant.name.uptodate|share-safe:        ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
  [formatvariant.name.uptodate|sparserevlog:      ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
  [formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no] (no-rust !)
  [formatvariant.name.mismatchdefault|persistent-nodemap:][formatvariant.repo.mismatchdefault| yes][formatvariant.config.special|    yes][formatvariant.default|      no] (rust !)
  [formatvariant.name.uptodate|copies-sdc:        ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.uptodate|revlog-v2:         ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.uptodate|changelog-v2:      ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.uptodate|plain-cl-delta:    ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
  [formatvariant.name.uptodate|compression:       ][formatvariant.repo.uptodate| zlib][formatvariant.config.default|   zlib][formatvariant.default|    zlib] (no-zstd !)
  [formatvariant.name.mismatchdefault|compression:       ][formatvariant.repo.mismatchdefault| zlib][formatvariant.config.special|   zlib][formatvariant.default|    zstd] (zstd !)
  [formatvariant.name.uptodate|compression-level: ][formatvariant.repo.uptodate| default][formatvariant.config.default| default][formatvariant.default| default]
  $ hg debugformat -Tjson
  [
   {
    "config": true,
    "default": true,
    "name": "fncache",
    "config": false,
    "default": false,
    "name": "dirstate-v2",
    "repo": false
   },
   {
    "config": true,
    "default": true,
    "name": "dotencode",
    "config": true,
    "default": true,
    "name": "generaldelta",
    "config": true,
    "default": true,
    "config": true,
    "default": true,
    "name": "sparserevlog",
    "repo": true
    "config": false, (no-rust !)
    "config": true, (rust !)
    "repo": false (no-rust !)
    "repo": true (rust !)
    "name": "copies-sdc",
    "repo": false
   },
   {
    "config": false,
    "default": false,
    "name": "revlog-v2",
    "repo": false
   },
   {
    "config": false,
    "default": false,
    "name": "changelog-v2",
    "repo": false
   },
   {
    "config": true,
    "default": true,
    "name": "plain-cl-delta",
    "default": "zlib", (no-zstd !)
    "default": "zstd", (zstd !)
    "name": "compression",
    "repo": "zlib"
   },
   {
    "config": "default",
    "default": "default",
    "name": "compression-level",
    "repo": "default"
  $ hg debugupgraderepo
  (no format upgrades found in existing repository)
  performing an upgrade with "--run" will make the following changes:
  
  requirements
     preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
  additional optimizations are available by specifying "--optimize <name>":
  
  re-delta-parent
     deltas within internal storage will be recalculated to choose an optimal base revision where this was not already done; the size of the repository may shrink and various operations may become faster; the first time this optimization is performed could slow down upgrade execution considerably; subsequent invocations should not run noticeably slower
  
  re-delta-multibase
     deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
  
  re-delta-all
     deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
  
  re-delta-fulladd
     every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
  $ hg debugupgraderepo --quiet
  requirements
     preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
--optimize can be used to add optimizations

  $ hg debugupgrade --optimize 're-delta-parent'
  (no format upgrades found in existing repository)
  performing an upgrade with "--run" will make the following changes:
  
  requirements
     preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
  optimisations: re-delta-parent
  
  re-delta-parent
     deltas within internal storage will choose a new base revision if needed
  
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  
  additional optimizations are available by specifying "--optimize <name>":
  
  re-delta-multibase
     deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
  
  re-delta-all
     deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
  
  re-delta-fulladd
     every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
  

modern form of the option

  $ hg debugupgrade --optimize re-delta-parent
  (no format upgrades found in existing repository)
  performing an upgrade with "--run" will make the following changes:
  
  requirements
     preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
  optimisations: re-delta-parent
  
  re-delta-parent
     deltas within internal storage will choose a new base revision if needed
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  
  additional optimizations are available by specifying "--optimize <name>":
  
  re-delta-multibase
     deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
  
  re-delta-all
     deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
  
  re-delta-fulladd
     every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
  
  $ hg debugupgrade --optimize re-delta-parent --quiet
  requirements
     preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
  
  optimisations: re-delta-parent
  
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  
passing multiple optimization:

  $ hg debugupgrade --optimize re-delta-parent --optimize re-delta-multibase --quiet
  requirements
     preserved: * (glob)
  
  optimisations: re-delta-multibase, re-delta-parent
  
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  

unknown optimization:

  $ hg debugupgrade --optimize foobar
  abort: unknown optimization action requested: foobar
  (run without arguments to see valid optimizations)
  [255]

Various sub-optimal detections work

  $ cat > .hg/requires << EOF
  > revlogv1
  > store
  > EOF

  $ hg debugformat
  sparserevlog:        no
  persistent-nodemap:  no
  copies-sdc:          no
  revlog-v2:           no
  plain-cl-delta:     yes
  compression:        zlib
  compression-level:  default
  $ hg debugformat --verbose
  format-variant     repo config default
  fncache:             no    yes     yes
  dotencode:           no    yes     yes
  generaldelta:        no    yes     yes
  share-safe:          no    yes     yes
  persistent-nodemap:  no     no      no (no-rust !)
  persistent-nodemap:  no    yes      no (rust !)
  revlog-v2:           no     no      no
  changelog-v2:        no     no      no
  compression:        zlib   zlib    zlib (no-zstd !)
  compression:        zlib   zlib    zstd (zstd !)
  compression-level:  default default default
  $ hg debugformat --verbose --config format.usegeneraldelta=no
  format-variant     repo config default
  fncache:             no    yes     yes
  dotencode:           no    yes     yes
  generaldelta:        no     no     yes
  share-safe:          no    yes     yes
  persistent-nodemap:  no     no      no (no-rust !)
  persistent-nodemap:  no    yes      no (rust !)
  revlog-v2:           no     no      no
  changelog-v2:        no     no      no
  compression:        zlib   zlib    zlib (no-zstd !)
  compression:        zlib   zlib    zstd (zstd !)
  compression-level:  default default default
  $ hg debugformat --verbose --config format.usegeneraldelta=no --color=debug
  format-variant     repo config default
  [formatvariant.name.mismatchconfig|fncache:           ][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|    yes][formatvariant.default|     yes]
  [formatvariant.name.uptodate|dirstate-v2:       ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.uptodate|tracked-hint:      ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.mismatchconfig|dotencode:         ][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|    yes][formatvariant.default|     yes]
  [formatvariant.name.mismatchdefault|generaldelta:      ][formatvariant.repo.mismatchdefault|  no][formatvariant.config.special|     no][formatvariant.default|     yes]
  [formatvariant.name.mismatchconfig|share-safe:        ][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|    yes][formatvariant.default|     yes]
  [formatvariant.name.mismatchdefault|sparserevlog:      ][formatvariant.repo.mismatchdefault|  no][formatvariant.config.special|     no][formatvariant.default|     yes]
  [formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no] (no-rust !)
  [formatvariant.name.mismatchconfig|persistent-nodemap:][formatvariant.repo.mismatchconfig|  no][formatvariant.config.special|    yes][formatvariant.default|      no] (rust !)
  [formatvariant.name.uptodate|copies-sdc:        ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.uptodate|revlog-v2:         ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.uptodate|changelog-v2:      ][formatvariant.repo.uptodate|  no][formatvariant.config.default|     no][formatvariant.default|      no]
  [formatvariant.name.uptodate|plain-cl-delta:    ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
  [formatvariant.name.uptodate|compression:       ][formatvariant.repo.uptodate| zlib][formatvariant.config.default|   zlib][formatvariant.default|    zlib] (no-zstd !)
  [formatvariant.name.mismatchdefault|compression:       ][formatvariant.repo.mismatchdefault| zlib][formatvariant.config.special|   zlib][formatvariant.default|    zstd] (zstd !)
  [formatvariant.name.uptodate|compression-level: ][formatvariant.repo.uptodate| default][formatvariant.config.default| default][formatvariant.default| default]
  $ hg debugupgraderepo
  note:    selecting all-filelogs for processing to change: dotencode
  note:    selecting all-manifestlogs for processing to change: dotencode
  note:    selecting changelog for processing to change: dotencode
  
  repository lacks features recommended by current config options:
  
  fncache
     long and reserved filenames may not work correctly; repository performance is sub-optimal
  
  dotencode
     storage of filenames beginning with a period or space may not work correctly
  
  generaldelta
     deltas within internal storage are unable to choose optimal revisions; repository is larger and slower than it could be; interaction with other repositories may require extra network and CPU resources, making "hg push" and "hg pull" slower
  
  share-safe
     old shared repositories do not share source repository requirements and config. This leads to various problems when the source repository format is upgraded or some new extensions are enabled.
  
  sparserevlog
     in order to limit disk reading and memory usage on older version, the span of a delta chain from its root to its end is limited, whatever the relevant data in this span. This can severly limit Mercurial ability to build good chain of delta resulting is much more storage space being taken and limit reusability of on disk delta during exchange.
  
  persistent-nodemap (rust !)
     persist the node -> rev mapping on disk to speedup lookup (rust !)
   (rust !)
  
  performing an upgrade with "--run" will make the following changes:
  
  requirements
     preserved: revlogv1, store
     added: dotencode, fncache, generaldelta, share-safe, sparserevlog (no-rust !)
     added: dotencode, fncache, generaldelta, persistent-nodemap, share-safe, sparserevlog (rust !)
  
  fncache
     repository will be more resilient to storing certain paths and performance of certain operations should be improved
  
  dotencode
     repository will be better able to store files beginning with a space or period
  
  generaldelta
     repository storage will be able to create optimal deltas; new repository data will be smaller and read times should decrease; interacting with other repositories using this storage model should require less network and CPU resources, making "hg push" and "hg pull" faster
  
  share-safe
     Upgrades a repository to share-safe format so that future shares of this repository share its requirements and configs.
  
  sparserevlog
     Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.
  
  persistent-nodemap (rust !)
     Speedup revision lookup by node id. (rust !)
   (rust !)
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  
  additional optimizations are available by specifying "--optimize <name>":
  
  re-delta-parent
     deltas within internal storage will be recalculated to choose an optimal base revision where this was not already done; the size of the repository may shrink and various operations may become faster; the first time this optimization is performed could slow down upgrade execution considerably; subsequent invocations should not run noticeably slower
  
  re-delta-multibase
     deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
  
  re-delta-all
     deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
  
  re-delta-fulladd
     every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
  $ hg debugupgraderepo --quiet
  requirements
     preserved: revlogv1, store
     added: dotencode, fncache, generaldelta, share-safe, sparserevlog (no-rust !)
     added: dotencode, fncache, generaldelta, persistent-nodemap, share-safe, sparserevlog (rust !)
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  

  $ hg --config format.dotencode=false debugupgraderepo
  note:    selecting all-filelogs for processing to change: fncache
  note:    selecting all-manifestlogs for processing to change: fncache
  note:    selecting changelog for processing to change: fncache
  
  repository lacks features recommended by current config options:
  
  fncache
     long and reserved filenames may not work correctly; repository performance is sub-optimal
  
  generaldelta
     deltas within internal storage are unable to choose optimal revisions; repository is larger and slower than it could be; interaction with other repositories may require extra network and CPU resources, making "hg push" and "hg pull" slower
  
  share-safe
     old shared repositories do not share source repository requirements and config. This leads to various problems when the source repository format is upgraded or some new extensions are enabled.
  
  sparserevlog
     in order to limit disk reading and memory usage on older version, the span of a delta chain from its root to its end is limited, whatever the relevant data in this span. This can severly limit Mercurial ability to build good chain of delta resulting is much more storage space being taken and limit reusability of on disk delta during exchange.
  
  persistent-nodemap (rust !)
     persist the node -> rev mapping on disk to speedup lookup (rust !)
   (rust !)
  repository lacks features used by the default config options:
  
  dotencode
     storage of filenames beginning with a period or space may not work correctly
  
  
  performing an upgrade with "--run" will make the following changes:
  
  requirements
     preserved: revlogv1, store
     added: fncache, generaldelta, share-safe, sparserevlog (no-rust !)
     added: fncache, generaldelta, persistent-nodemap, share-safe, sparserevlog (rust !)
  
  fncache
     repository will be more resilient to storing certain paths and performance of certain operations should be improved
  
  generaldelta
     repository storage will be able to create optimal deltas; new repository data will be smaller and read times should decrease; interacting with other repositories using this storage model should require less network and CPU resources, making "hg push" and "hg pull" faster
  
  share-safe
     Upgrades a repository to share-safe format so that future shares of this repository share its requirements and configs.
  
  sparserevlog
     Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.
  
  persistent-nodemap (rust !)
     Speedup revision lookup by node id. (rust !)
   (rust !)
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  
  additional optimizations are available by specifying "--optimize <name>":
  
  re-delta-parent
     deltas within internal storage will be recalculated to choose an optimal base revision where this was not already done; the size of the repository may shrink and various operations may become faster; the first time this optimization is performed could slow down upgrade execution considerably; subsequent invocations should not run noticeably slower
  
  re-delta-multibase
     deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
  
  re-delta-all
     deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
  
  re-delta-fulladd
     every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
  $ cd ..

Upgrading a repository that is already modern essentially no-ops

  $ hg init modern
  $ hg -R modern debugupgraderepo --run

Upgrading a repository to generaldelta works

  $ hg --config format.usegeneraldelta=false init upgradegd
  $ cd upgradegd
  $ touch f0
  $ hg -q commit -A -m initial
  $ mkdir FooBarDirectory.d
  $ touch FooBarDirectory.d/f1
  $ hg -q commit -A -m 'add f1'
  $ hg -q up -r 0
  >>> import random
  >>> random.seed(0) # have a reproducible content
  >>> with open("f2", "wb") as f:
  ...     for i in range(100000):
  ...         f.write(b"%d\n" % random.randint(1000000000, 9999999999)) and None
  $ hg -q commit -A -m 'add f2'

make sure we have a .d file

  $ ls -d .hg/store/data/*
  .hg/store/data/_foo_bar_directory.d.hg
  .hg/store/data/f0.i
  .hg/store/data/f2.d
  .hg/store/data/f2.i

  $ hg debugupgraderepo --run --config format.sparse-revlog=false
  note:    selecting all-filelogs for processing to change: generaldelta
  note:    selecting all-manifestlogs for processing to change: generaldelta
  note:    selecting changelog for processing to change: generaldelta
  
  upgrade will perform the following actions:
  
  requirements
     preserved: dotencode, fncache, revlogv1, share-safe, store (no-rust !)
     preserved: dotencode, fncache, persistent-nodemap, revlogv1, share-safe, store (rust !)
     added: generaldelta
  
  generaldelta
     repository storage will be able to create optimal deltas; new repository data will be smaller and read times should decrease; interacting with other repositories using this storage model should require less network and CPU resources, making "hg push" and "hg pull" faster
  
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  
  beginning upgrade...
  repository locked and read-only
  creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
  (it is safe to interrupt this process any time before data migration completes)
  migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
  migrating 519 KB in store; 1.05 MB tracked data
  migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
  finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
  migrating 1 manifests containing 3 revisions (384 bytes in store; 238 bytes tracked data)
  finished migrating 3 manifest revisions across 1 manifests; change in size: -17 bytes
  migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
  finished migrating 3 changelog revisions; change in size: 0 bytes
  finished migrating 9 total revisions; total change in store size: -17 bytes
  copying requires
  data fully upgraded in a temporary repository
  marking source repository as being upgraded; clients will be unable to read from repository
  starting in-place swap of repository data
  replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
  replacing store...
  store replacement complete; repository was inconsistent for *s (glob)
  finalizing requirements file and making repository readable again
  removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
  copy of old repository backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
  the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified

Original requirements backed up

  $ cat .hg/upgradebackup.*/requires
  share-safe
  $ cat .hg/upgradebackup.*/store/requires
  upgradeinprogress

generaldelta added to original requirements files

  dotencode
  fncache
  generaldelta
store directory has files we expect

  $ ls .hg/store
  00changelog-????????.nd (glob) (rust !)
  00changelog.d
  00changelog.i
  00changelog.n (rust !)
  00manifest.i
  data
  undo
  undo.backupfiles

manifest should be generaldelta

  $ hg debugrevlog -m | grep flags
  flags  : inline, generaldelta

verify should be happy


old store should be backed up

  $ ls -d .hg/upgradebackup.*/
  .hg/upgradebackup.*/ (glob)
  $ ls .hg/upgradebackup.*/store
  00changelog-????????.nd (glob) (rust !)
  00changelog.d
  00changelog.i
  00changelog.n (rust !)
  00manifest.i
  data
  fncache
  phaseroots
  undo.backup.00changelog.n.bck (rust !)
  undo.backup.fncache.bck
unless --no-backup is passed

  $ rm -rf .hg/upgradebackup.*/
  $ hg debugupgraderepo --run --no-backup
  note:    selecting all-filelogs for processing to change: sparserevlog
  note:    selecting all-manifestlogs for processing to change: sparserevlog
  note:    selecting changelog for processing to change: sparserevlog
  
  upgrade will perform the following actions:
  
  requirements
     preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, store (no-rust !)
     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, store (rust !)
     added: sparserevlog
  
  sparserevlog
     Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.
  
  processed revlogs:
    - all-filelogs
    - changelog
    - manifest
  
  beginning upgrade...
  repository locked and read-only
  creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
  (it is safe to interrupt this process any time before data migration completes)
  migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
  migrating 519 KB in store; 1.05 MB tracked data
  migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
  finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
  migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
  finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
  migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
  finished migrating 3 changelog revisions; change in size: 0 bytes
  finished migrating 9 total revisions; total change in store size: 0 bytes
  copying phaseroots
  copying requires
  data fully upgraded in a temporary repository
  marking source repository as being upgraded; clients will be unable to read from repository
  starting in-place swap of repository data
  replacing store...
  store replacement complete; repository was inconsistent for * (glob)
  finalizing requirements file and making repository readable again
  removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
  $ ls -1 .hg/ | grep upgradebackup
  [1]

We can restrict optimization to some revlog:

  $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup --debug --traceback
  upgrade will perform the following actions:
  
  requirements
     preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
  optimisations: re-delta-parent
  
  re-delta-parent
     deltas within internal storage will choose a new base revision if needed
  
  beginning upgrade...
  repository locked and read-only
  creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
  (it is safe to interrupt this process any time before data migration completes)
  migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
  migrating 519 KB in store; 1.05 MB tracked data
  migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
  blindly copying data/FooBarDirectory.d/f1.i containing 1 revisions
  blindly copying data/f0.i containing 1 revisions
  blindly copying data/f2.i containing 1 revisions
  finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
  migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
  cloning 3 revisions from 00manifest.i
  finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
  migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
  blindly copying 00changelog.i containing 3 revisions
  finished migrating 3 changelog revisions; change in size: 0 bytes
  finished migrating 9 total revisions; total change in store size: 0 bytes
  copying phaseroots
  copying requires
  data fully upgraded in a temporary repository
  marking source repository as being upgraded; clients will be unable to read from repository
  starting in-place swap of repository data
  replacing store...
  store replacement complete; repository was inconsistent for *s (glob)
  finalizing requirements file and making repository readable again
  removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)

Check that the repo still works fine

  $ hg log -G --stat
  @  changeset:   2:fca376863211
  |  tag:         tip
  |  parent:      0:ba592bf28da2
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     add f2
  |
  |   f2 |  100000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  |   1 files changed, 100000 insertions(+), 0 deletions(-)
  |/   user:        test
  |    date:        Thu Jan 01 00:00:00 1970 +0000
  |    summary:     add f1
  |
  |
  o  changeset:   0:ba592bf28da2
     user:        test
     date:        Thu Jan 01 00:00:00 1970 +0000
     summary:     initial