[PATCH 2 of 3 V2] upgrade: add an argument to control changelog upgrade

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Aug 7 10:29:34 EDT 2019


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1564500316 -7200
#      Tue Jul 30 17:25:16 2019 +0200
# Node ID acf1937e39ba1db0ab81a14bc0c0082c93df838b
# Parent  8a77cda93b1a7252482a4ca4e420b76936c9ae27
# EXP-Topic upgrade-select
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r acf1937e39ba
upgrade: add an argument to control changelog upgrade

Same as for `--manifest` we can now select more selection.

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2848,6 +2848,7 @@ def debugupdatecaches(ui, repo, *pats, *
     ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
     ('', 'run', False, _('performs an upgrade')),
     ('', 'backup', True, _('keep the old repository content around')),
+    ('', 'changelog', None, _('select the changelog for upgrade')),
     ('', 'manifest', None, _('select the manifest for upgrade')),
 ])
 def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True, **opts):
@@ -2874,6 +2875,8 @@ def debugupgraderepo(ui, repo, run=False
 
       * `--manifest`: only optimize the manifest
       * `--no-manifest`: optimize all revlog but the manifest
+      * `--changelog`: optimize the changelog only
+      * `--no-changelog --no-manifest`: optimize filelogs only
     """
     return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize,
                                backup=backup, **opts)
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -865,7 +865,7 @@ def _upgraderepo(ui, srcrepo, dstrepo, r
     return backuppath
 
 def upgraderepo(ui, repo, run=False, optimize=None, backup=True,
-                manifest=None):
+                manifest=None, changelog=None):
     """Upgrade a repository in place."""
     if optimize is None:
         optimize = []
@@ -873,7 +873,7 @@ def upgraderepo(ui, repo, run=False, opt
     repo = repo.unfiltered()
 
     revlogs = set(UPGRADE_ALL_REVLOGS)
-    specentries = (('m', manifest),)
+    specentries = (('c', changelog), ('m', manifest))
     specified = [(y, x) for (y, x) in specentries if x is not None]
     if specified:
         # we have some limitation on revlogs to be recloned
@@ -881,15 +881,18 @@ def upgraderepo(ui, repo, run=False, opt
             revlogs = set()
             for r, enabled in specified:
                 if enabled:
-                    if r == 'm':
+                    if r == 'c':
+                        revlogs.add(UPGRADE_CHANGELOG)
+                    elif r == 'm':
                         revlogs.add(UPGRADE_MANIFEST)
         else:
             # none are enabled
             for r, __ in specified:
-                if r == 'm':
+                if r == 'c':
+                    revlogs.discard(UPGRADE_CHANGELOG)
+                elif r == 'm':
                     revlogs.discard(UPGRADE_MANIFEST)
 
-
     # Ensure the repository can be upgraded.
     missingreqs = requiredsourcerequirements(repo) - repo.requirements
     if missingreqs:
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -312,7 +312,7 @@ Show all commands + options
   debuguigetpass: prompt
   debuguiprompt: prompt
   debugupdatecaches: 
-  debugupgraderepo: optimize, run, backup, manifest
+  debugupgraderepo: optimize, run, backup, changelog, manifest
   debugwalk: include, exclude
   debugwhyunstable: 
   debugwireargs: three, four, five, ssh, remotecmd, insecure
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -636,6 +636,98 @@ Check we can select negatively
   checking files
   checked 3 changesets with 3 changes to 3 files
 
+Check that we can select changelog only
+
+  $ hg debugupgrade --optimize re-delta-parent --run --changelog --no-backup --debug --traceback
+  upgrade will perform the following actions:
+  
+  requirements
+     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
+  
+  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 migrated 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 917 bytes in store; 401 bytes tracked data
+  migrating 3 filelogs containing 3 revisions (192 bytes in store; 0 bytes tracked data)
+  blindly copying data/f0.i containing 1 revisions
+  blindly copying data/f1.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 (349 bytes in store; 220 bytes tracked data)
+  blindly copying 00manifest.i containing 3 revisions
+  finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
+  migrating changelog containing 3 revisions (376 bytes in store; 181 bytes tracked data)
+  cloning 3 revisions from 00changelog.i
+  finished migrating 3 changelog revisions; change in size: 0 bytes
+  finished migrating 9 total revisions; total change in store size: 0 bytes
+  copying phaseroots
+  data fully migrated to 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 old repository content$TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
+  removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
+  $ hg verify
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  checked 3 changesets with 3 changes to 3 files
+
+Check that we can select filelog only
+
+  $ hg debugupgrade --optimize re-delta-parent --run --no-changelog --no-manifest --no-backup --debug --traceback
+  upgrade will perform the following actions:
+  
+  requirements
+     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
+  
+  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 migrated 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 917 bytes in store; 401 bytes tracked data
+  migrating 3 filelogs containing 3 revisions (192 bytes in store; 0 bytes tracked data)
+  cloning 1 revisions from data/f0.i
+  cloning 1 revisions from data/f1.i
+  cloning 1 revisions from data/f2.i
+  finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
+  migrating 1 manifests containing 3 revisions (349 bytes in store; 220 bytes tracked data)
+  blindly copying 00manifest.i containing 3 revisions
+  finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
+  migrating changelog containing 3 revisions (376 bytes in store; 181 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
+  data fully migrated to 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 old repository content$TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
+  removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
+  $ hg verify
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  checked 3 changesets with 3 changes to 3 files
+
   $ cd ..
 
 store files with special filenames aren't encoded during copy


More information about the Mercurial-devel mailing list