changeset 46231:d3113c4cf52c

upgrade: don't perform anything if nothing to do Before this patch, upgrade will process everything, re-clone all revlogs, write requirements file again even there is no change to be made. This patch makes it exit earlier. Differential Revision: https://phab.mercurial-scm.org/D9695
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 08 Jan 2021 23:08:39 +0530
parents 1fcab88ab85c
children eb01d6d00a50
files mercurial/upgrade.py tests/test-lfs-serve.t tests/test-upgrade-repo.t
diffstat 3 files changed, 8 insertions(+), 173 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/upgrade.py	Fri Jan 08 23:06:38 2021 +0530
+++ b/mercurial/upgrade.py	Fri Jan 08 23:08:39 2021 +0530
@@ -171,6 +171,9 @@
             upgrade_op.print_unused_optimizations()
         return
 
+    if not (upgrade_op.upgrade_actions or upgrade_op.removed_actions):
+        ui.status(_(b'nothing to do\n'))
+        return
     # Else we're in the run=true case.
     ui.write(_(b'upgrade will perform the following actions:\n\n'))
     upgrade_op.print_requirements()
--- a/tests/test-lfs-serve.t	Fri Jan 08 23:06:38 2021 +0530
+++ b/tests/test-lfs-serve.t	Fri Jan 08 23:08:39 2021 +0530
@@ -128,16 +128,6 @@
   @@ -0,0 +1,1 @@
   +non-lfs
   *** runcommand debugupgraderepo -q --run
-  upgrade will perform the following actions:
-  
-  requirements
-     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
-  
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
-  
 
   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   [1]
--- a/tests/test-upgrade-repo.t	Fri Jan 08 23:06:38 2021 +0530
+++ b/tests/test-upgrade-repo.t	Fri Jan 08 23:08:39 2021 +0530
@@ -471,30 +471,7 @@
 
   $ hg init modern
   $ hg -R modern debugupgraderepo --run
-  upgrade will perform the following actions:
-  
-  requirements
-     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
-  
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
-  
-  beginning upgrade...
-  repository locked and read-only
-  creating temporary repository to stage upgraded data: $TESTTMP/modern/.hg/upgrade.* (glob)
-  (it is safe to interrupt this process any time before data migration completes)
-  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/modern/.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/modern/.hg/upgrade.* (glob)
-  copy of old repository backed up at $TESTTMP/modern/.hg/upgradebackup.* (glob)
-  the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
+  nothing to do
 
 Upgrading a repository to generaldelta works
 
@@ -1025,41 +1002,7 @@
   $ touch .hg/store/.XX_special_filename
 
   $ hg debugupgraderepo --run
-  upgrade will perform the following actions:
-  
-  requirements
-     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
-  
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
-  
-  beginning upgrade...
-  repository locked and read-only
-  creating temporary repository to stage upgraded data: $TESTTMP/store-filenames/.hg/upgrade.* (glob)
-  (it is safe to interrupt this process any time before data migration completes)
-  migrating 3 total revisions (1 in filelogs, 1 in manifests, 1 in changelog)
-  migrating 301 bytes in store; 107 bytes tracked data
-  migrating 1 filelogs containing 1 revisions (64 bytes in store; 0 bytes tracked data)
-  finished migrating 1 filelog revisions across 1 filelogs; change in size: 0 bytes
-  migrating 1 manifests containing 1 revisions (110 bytes in store; 45 bytes tracked data)
-  finished migrating 1 manifest revisions across 1 manifests; change in size: 0 bytes
-  migrating changelog containing 1 revisions (127 bytes in store; 62 bytes tracked data)
-  finished migrating 1 changelog revisions; change in size: 0 bytes
-  finished migrating 3 total revisions; total change in store size: 0 bytes
-  copying .XX_special_filename
-  copying phaseroots
-  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/store-filenames/.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/store-filenames/.hg/upgrade.* (glob)
-  copy of old repository backed up at $TESTTMP/store-filenames/.hg/upgradebackup.* (glob)
-  the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
+  nothing to do
   $ hg debugupgraderepo --run --optimize 're-delta-fulladd'
   upgrade will perform the following actions:
   
@@ -1132,40 +1075,7 @@
   store
 
   $ hg debugupgraderepo --run
-  upgrade will perform the following actions:
-  
-  requirements
-     preserved: dotencode, fncache, generaldelta, largefiles, revlogv1, sparserevlog, store
-  
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
-  
-  beginning upgrade...
-  repository locked and read-only
-  creating temporary repository to stage upgraded data: $TESTTMP/largefilesrepo/.hg/upgrade.* (glob)
-  (it is safe to interrupt this process any time before data migration completes)
-  migrating 3 total revisions (1 in filelogs, 1 in manifests, 1 in changelog)
-  migrating 355 bytes in store; 160 bytes tracked data
-  migrating 1 filelogs containing 1 revisions (106 bytes in store; 41 bytes tracked data)
-  finished migrating 1 filelog revisions across 1 filelogs; change in size: 0 bytes
-  migrating 1 manifests containing 1 revisions (116 bytes in store; 51 bytes tracked data)
-  finished migrating 1 manifest revisions across 1 manifests; change in size: 0 bytes
-  migrating changelog containing 1 revisions (133 bytes in store; 68 bytes tracked data)
-  finished migrating 1 changelog revisions; change in size: 0 bytes
-  finished migrating 3 total revisions; total change in store size: 0 bytes
-  copying phaseroots
-  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/largefilesrepo/.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/largefilesrepo/.hg/upgrade.* (glob)
-  copy of old repository backed up at $TESTTMP/largefilesrepo/.hg/upgradebackup.* (glob)
-  the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
+  nothing to do
   $ cat .hg/requires
   dotencode
   fncache
@@ -1190,41 +1100,7 @@
   .hg/store/lfs/objects/d0/beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
 
   $ hg debugupgraderepo --run
-  upgrade will perform the following actions:
-  
-  requirements
-     preserved: dotencode, fncache, generaldelta, largefiles, lfs, revlogv1, sparserevlog, store
-  
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
-  
-  beginning upgrade...
-  repository locked and read-only
-  creating temporary repository to stage upgraded data: $TESTTMP/largefilesrepo/.hg/upgrade.* (glob)
-  (it is safe to interrupt this process any time before data migration completes)
-  migrating 6 total revisions (2 in filelogs, 2 in manifests, 2 in changelog)
-  migrating 801 bytes in store; 467 bytes tracked data
-  migrating 2 filelogs containing 2 revisions (296 bytes in store; 182 bytes tracked data)
-  finished migrating 2 filelog revisions across 2 filelogs; change in size: 0 bytes
-  migrating 1 manifests containing 2 revisions (241 bytes in store; 151 bytes tracked data)
-  finished migrating 2 manifest revisions across 1 manifests; change in size: 0 bytes
-  migrating changelog containing 2 revisions (264 bytes in store; 134 bytes tracked data)
-  finished migrating 2 changelog revisions; change in size: 0 bytes
-  finished migrating 6 total revisions; total change in store size: 0 bytes
-  copying phaseroots
-  copying lfs blob d0beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
-  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/largefilesrepo/.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/largefilesrepo/.hg/upgrade.* (glob)
-  copy of old repository backed up at $TESTTMP/largefilesrepo/.hg/upgradebackup.* (glob)
-  the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
+  nothing to do
 
   $ grep lfs .hg/requires
   lfs
@@ -1646,40 +1522,6 @@
   $ hg debugsidedata -c 0
 
 Demonstrate that nothing to perform upgrade will still run all the way through
-FIXME: this should return early
 
   $ hg debugupgraderepo --run
-  upgrade will perform the following actions:
-  
-  requirements
-     preserved: dotencode, exp-sidedata-flag, fncache, generaldelta, revlog-compression-zstd, revlogv1, sparserevlog, store
-  
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
-  
-  beginning upgrade...
-  repository locked and read-only
-  creating temporary repository to stage upgraded data: $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
-  (it is safe to interrupt this process any time before data migration completes)
-  migrating 3 total revisions (1 in filelogs, 1 in manifests, 1 in changelog)
-  migrating 297 bytes in store; 103 bytes tracked data
-  migrating 1 filelogs containing 1 revisions (64 bytes in store; 0 bytes tracked data)
-  finished migrating 1 filelog revisions across 1 filelogs; change in size: 0 bytes
-  migrating 1 manifests containing 1 revisions (110 bytes in store; 45 bytes tracked data)
-  finished migrating 1 manifest revisions across 1 manifests; change in size: 0 bytes
-  migrating changelog containing 1 revisions (123 bytes in store; 58 bytes tracked data)
-  finished migrating 1 changelog revisions; change in size: 0 bytes
-  finished migrating 3 total revisions; total change in store size: 0 bytes
-  copying phaseroots
-  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/sparserevlogrepo/.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/sparserevlogrepo/.hg/upgrade.* (glob)
-  copy of old repository backed up at $TESTTMP/sparserevlogrepo/.hg/upgradebackup.* (glob)
-  the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
+  nothing to do