Patchwork D9695: upgrade: don't perform anything if nothing to do

login
register
mail settings
Submitter phabricator
Date Jan. 8, 2021, 6:45 p.m.
Message ID <differential-rev-PHID-DREV-ardylz3lhblfpvpbulxe-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48006/
State Superseded
Headers show

Comments

phabricator - Jan. 8, 2021, 6:45 p.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9695

AFFECTED FILES
  mercurial/upgrade.py
  tests/test-lfs-serve.t
  tests/test-upgrade-repo.t

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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
@@ -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.1xrhgkjm
-  (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.0xno10pk
-  replacing store...
-  store replacement complete; repository was inconsistent for 0.0s
-  finalizing requirements file and making repository readable again
-  removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.1xrhgkjm
-  copy of old repository backed up at $TESTTMP/sparserevlogrepo/.hg/upgradebackup.0xno10pk
-  the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
+  nothing to do
diff --git a/tests/test-lfs-serve.t b/tests/test-lfs-serve.t
--- a/tests/test-lfs-serve.t
+++ b/tests/test-lfs-serve.t
@@ -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]
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -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()