Skip to content
Snippets Groups Projects
Commit c407513a44a3 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

upgrade: start moving the "to be happening" data in a dedicated object

The upgrade code has a lot of logic to determine which action needs to be
performed depending of various element (sometimes depending from each other). It
would be nice to have a consistent object representing this. That could be
cleanly passed and avoid some logic duplication.

So we create this object as a start.

Differential Revision: https://phab.mercurial-scm.org/D9487
parent 7740d5102760
No related branches found
No related tags found
Loading
......@@ -176,6 +176,12 @@
ui.write((b' - %s\n' % r))
ui.write((b'\n'))
upgrade_op = upgrade_actions.UpgradeOperation(
newreqs,
[a.name for a in actions],
revlogs,
)
if not run:
fromconfig = []
onlydefault = []
......@@ -249,8 +255,6 @@
printupgradeactions()
print_affected_revlogs()
upgradeactions = [a.name for a in actions]
ui.status(_(b'beginning upgrade...\n'))
with repo.wlock(), repo.lock():
ui.status(_(b'repository locked and read-only\n'))
......@@ -276,7 +280,7 @@
with dstrepo.wlock(), dstrepo.lock():
backuppath = upgrade_engine.upgrade(
ui, repo, dstrepo, newreqs, upgradeactions, revlogs=revlogs
ui, repo, dstrepo, upgrade_op
)
if not (backup or backuppath is None):
ui.status(
......
......@@ -554,6 +554,15 @@
return newactions
class UpgradeOperation(object):
"""represent the work to be done during an upgrade"""
def __init__(self, requirements, actions, revlogs_to_process):
self.requirements = requirements
self.actions = actions
self.revlogs_to_process = revlogs_to_process
### Code checking if a repository can got through the upgrade process at all. #
......
......@@ -383,9 +383,7 @@
"""
def upgrade(
ui, srcrepo, dstrepo, requirements, actions, revlogs=UPGRADE_ALL_REVLOGS
):
def upgrade(ui, srcrepo, dstrepo, upgrade_op):
"""Do the low-level work of upgrading a repository.
The upgrade is effectively performed as a copy between a source
......@@ -405,5 +403,5 @@
)
)
if b're-delta-all' in actions:
if b're-delta-all' in upgrade_op.actions:
deltareuse = revlog.revlog.DELTAREUSENEVER
......@@ -409,3 +407,3 @@
deltareuse = revlog.revlog.DELTAREUSENEVER
elif b're-delta-parent' in actions:
elif b're-delta-parent' in upgrade_op.actions:
deltareuse = revlog.revlog.DELTAREUSESAMEREVS
......@@ -411,3 +409,3 @@
deltareuse = revlog.revlog.DELTAREUSESAMEREVS
elif b're-delta-multibase' in actions:
elif b're-delta-multibase' in upgrade_op.actions:
deltareuse = revlog.revlog.DELTAREUSESAMEREVS
......@@ -413,5 +411,5 @@
deltareuse = revlog.revlog.DELTAREUSESAMEREVS
elif b're-delta-fulladd' in actions:
elif b're-delta-fulladd' in upgrade_op.actions:
deltareuse = revlog.revlog.DELTAREUSEFULLADD
else:
deltareuse = revlog.revlog.DELTAREUSEALWAYS
......@@ -423,10 +421,10 @@
dstrepo,
tr,
deltareuse,
b're-delta-multibase' in actions,
revlogs=revlogs,
b're-delta-multibase' in upgrade_op.actions,
revlogs=upgrade_op.revlogs_to_process,
)
# Now copy other files in the store directory.
# The sorted() makes execution deterministic.
for p, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
......@@ -428,9 +426,11 @@
)
# Now copy other files in the store directory.
# The sorted() makes execution deterministic.
for p, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
if not _filterstorefile(srcrepo, dstrepo, requirements, p, kind, st):
if not _filterstorefile(
srcrepo, dstrepo, upgrade_op.requirements, p, kind, st
):
continue
srcrepo.ui.status(_(b'copying %s\n') % p)
......@@ -489,7 +489,7 @@
b'again\n'
)
)
scmutil.writereporequirements(srcrepo, requirements)
scmutil.writereporequirements(srcrepo, upgrade_op.requirements)
# The lock file from the old store won't be removed because nothing has a
# reference to its new location. So clean it up manually. Alternatively, we
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment