@@ -10,6 +10,7 @@ from __future__ import absolute_import
import errno
import hashlib
+import stat
import tempfile
import time
@@ -798,6 +799,44 @@ def _copyrevlogs(ui, srcrepo, dstrepo, t
ui.write(_('finished migrating %d total revisions; total change in store '
'size: %s\n') % (revcount, util.bytecount(dstsize - srcsize)))
+def _upgradefilterstorefile(srcrepo, dstrepo, requirements, path, mode, st):
+ """Determine whether to copy a store file during upgrade.
+
+ This function is called when migrating store files from ``srcrepo`` to
+ ``dstrepo`` as part of upgrading a repository.
+
+ Args:
+ srcrepo: repo we are copying from
+ dstrepo: repo we are copying to
+ requirements: set of requirements for ``dstrepo``
+ path: store file being examined
+ mode: the ``ST_MODE`` file type of ``path``
+ st: ``stat`` data structure for ``path``
+
+ Function should return ``True`` if the file is to be copied.
+ """
+ # Skip revlogs.
+ if path.endswith(('.i', '.d')):
+ return False
+ # Skip transaction related files.
+ if path.startswith('undo'):
+ return False
+ # Only copy regular files.
+ if mode != stat.S_IFREG:
+ return False
+ # Skip other skipped files.
+ if path in ('lock', 'fncache'):
+ return False
+
+ return True
+
+def _upgradefinishdatamigration(ui, srcrepo, dstrepo, requirements):
+ """Hook point for extensions to perform additional actions during upgrade.
+
+ This function is called after revlogs and store files have been copied but
+ before the new store is swapped into the original location.
+ """
+
def _upgraderepo(ui, srcrepo, dstrepo, requirements, actions):
"""Do the low-level work of upgrading a repository.
@@ -827,7 +866,18 @@ def _upgraderepo(ui, srcrepo, dstrepo, r
_copyrevlogs(ui, srcrepo, dstrepo, tr, deltareuse,
'redeltamultibase' in actions)
- # TODO copy non-revlog store files
+ # Now copy other files in the store directory.
+ for p, kind, st in srcrepo.store.vfs.readdir('', stat=True):
+ if not _upgradefilterstorefile(srcrepo, dstrepo, requirements,
+ p, kind, st):
+ continue
+
+ srcrepo.ui.write(_('copying %s\n') % p)
+ src = srcrepo.store.vfs.join(p)
+ dst = dstrepo.store.vfs.join(p)
+ util.copyfile(src, dst, copystat=True)
+
+ _upgradefinishdatamigration(ui, srcrepo, dstrepo, requirements)
ui.write(_('data fully migrated to temporary repository\n'))
@@ -241,6 +241,7 @@ Upgrading a repository to generaldelta w
migrating changelog containing 3 revisions (184 bytes in store; 181 bytes tracked data)
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
@@ -276,6 +277,7 @@ store directory has files we expect
00manifest.i
data
fncache
+ phaseroots
undo
undo.backupfiles
undo.phaseroots