Patchwork [2,of,2] largefiles: allow to run 'debugupgraderepo' on repo with largefiles

login
register
mail settings
Submitter Boris Feld
Date Dec. 7, 2017, 12:06 p.m.
Message ID <f8066f6c62b2bd6e0f28.1512648370@FB>
Download mbox | patch
Permalink /patch/25992/
State Accepted
Headers show

Comments

Boris Feld - Dec. 7, 2017, 12:06 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1512607994 -3600
#      Thu Dec 07 01:53:14 2017 +0100
# Node ID f8066f6c62b2bd6e0f28dd3ed283c8a265497fc0
# Parent  858933ee312507ecd05498ff72f7c4f7a4802b80
# EXP-Topic updaterepo.largefiles
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f8066f6c62b2
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.
Augie Fackler - Dec. 7, 2017, 10:34 p.m.
On Thu, Dec 07, 2017 at 01:06:10PM +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1512607994 -3600
> #      Thu Dec 07 01:53:14 2017 +0100
> # Node ID f8066f6c62b2bd6e0f28dd3ed283c8a265497fc0
> # Parent  858933ee312507ecd05498ff72f7c4f7a4802b80
> # EXP-Topic updaterepo.largefiles
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f8066f6c62b2
> largefiles: allow to run 'debugupgraderepo' on repo with largefiles

queued, thanks

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1470,3 +1470,9 @@  def scmutilmarktouched(orig, repo, files
                                 printmessage=False, normallookup=True)
 
     return result
+
+def upgraderequirements(orig, repo):
+    reqs = orig(repo)
+    if 'largefiles' in repo.requirements:
+        reqs.add('largefiles')
+    return reqs
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -30,6 +30,7 @@  from mercurial import (
     scmutil,
     sshpeer,
     subrepo,
+    upgrade,
     wireproto,
 )
 
@@ -60,6 +61,12 @@  def uisetup(ui):
 
     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)
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
@@ -352,3 +352,62 @@  store files with special filenames aren'
   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