changeset 35303:67b7e39b441b

largefiles: allow to run 'debugupgraderepo' on repo with largefiles The extensions wrap the necessary function to ensure the 'largefiles' requirements won't be dropped. It is now possible to run `hg debugupgraderepo` on a repository with largefiles.
author Boris Feld <boris.feld@octobus.net>
date Thu, 07 Dec 2017 01:53:14 +0100
parents ad2b35ebf670
children f77121b6bf1b
files hgext/largefiles/overrides.py hgext/largefiles/uisetup.py tests/test-upgrade-repo.t
diffstat 3 files changed, 72 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Thu Dec 07 01:51:54 2017 +0100
+++ b/hgext/largefiles/overrides.py	Thu Dec 07 01:53:14 2017 +0100
@@ -1470,3 +1470,9 @@
                                 printmessage=False, normallookup=True)
 
     return result
+
+def upgraderequirements(orig, repo):
+    reqs = orig(repo)
+    if 'largefiles' in repo.requirements:
+        reqs.add('largefiles')
+    return reqs
--- a/hgext/largefiles/uisetup.py	Thu Dec 07 01:51:54 2017 +0100
+++ b/hgext/largefiles/uisetup.py	Thu Dec 07 01:53:14 2017 +0100
@@ -30,6 +30,7 @@
     scmutil,
     sshpeer,
     subrepo,
+    upgrade,
     wireproto,
 )
 
@@ -60,6 +61,12 @@
 
     extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies)
 
+    extensions.wrapfunction(upgrade, 'preservedrequirements',
+                            overrides.upgraderequirements)
+
+    extensions.wrapfunction(upgrade, 'supporteddestrequirements',
+                            overrides.upgraderequirements)
+
     # Subrepos call status function
     entry = extensions.wrapcommand(commands.table, 'status',
                                    overrides.overridestatus)
--- a/tests/test-upgrade-repo.t	Thu Dec 07 01:51:54 2017 +0100
+++ b/tests/test-upgrade-repo.t	Thu Dec 07 01:53:14 2017 +0100
@@ -352,3 +352,62 @@
   the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
 
   $ cd ..
+
+Check upgrading a large file repository
+---------------------------------------
+
+  $ hg init largefilesrepo
+  $ cat << EOF >> largefilesrepo/.hg/hgrc
+  > [extensions]
+  > largefiles =
+  > EOF
+
+  $ cd largefilesrepo
+  $ touch foo
+  $ hg add --large foo
+  $ hg -q commit -m initial
+  $ cat .hg/requires
+  dotencode
+  fncache
+  generaldelta
+  largefiles
+  revlogv1
+  store
+
+  $ hg debugupgraderepo --run
+  upgrade will perform the following actions:
+  
+  requirements
+     preserved: dotencode, fncache, generaldelta, largefiles, revlogv1, store
+  
+  beginning upgrade...
+  repository locked and read-only
+  creating temporary repository to stage migrated 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 163 bytes in store; 160 bytes tracked data
+  migrating 1 filelogs containing 1 revisions (42 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 (52 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 (69 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 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/largefilesrepo/.hg/upgradebackup.* (glob)
+  replacing store...
+  store replacement complete; repository was inconsistent for 0.0s
+  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
+  $ cat .hg/requires
+  dotencode
+  fncache
+  generaldelta
+  largefiles
+  revlogv1
+  store