##// END OF EJS Templates
upgrade: move `printrequirements()` to UpgradeOperation class...
Pulkit Goyal -
r46807:aba979b1 default
parent child Browse files
Show More
@@ -123,36 +123,10 b' def upgraderepo('
123 123 ui.warn(msg % b', '.join(sorted(incompatible)))
124 124 revlogs = upgrade_engine.UPGRADE_ALL_REVLOGS
125 125
126 def write_labeled(l, label):
127 first = True
128 for r in sorted(l):
129 if not first:
130 ui.write(b', ')
131 ui.write(r, label=label)
132 first = False
133
134 def printrequirements():
135 ui.write(_(b'requirements\n'))
136 ui.write(_(b' preserved: '))
137 write_labeled(
138 newreqs & repo.requirements, "upgrade-repo.requirement.preserved"
139 )
140 ui.write((b'\n'))
141 removed = repo.requirements - newreqs
142 if repo.requirements - newreqs:
143 ui.write(_(b' removed: '))
144 write_labeled(removed, "upgrade-repo.requirement.removed")
145 ui.write((b'\n'))
146 added = newreqs - repo.requirements
147 if added:
148 ui.write(_(b' added: '))
149 write_labeled(added, "upgrade-repo.requirement.added")
150 ui.write((b'\n'))
151 ui.write(b'\n')
152
153 126 upgrade_op = upgrade_actions.UpgradeOperation(
154 127 ui,
155 128 newreqs,
129 repo.requirements,
156 130 actions,
157 131 revlogs,
158 132 )
@@ -205,7 +179,7 b' def upgraderepo('
205 179 )
206 180 )
207 181
208 printrequirements()
182 upgrade_op.print_requirements()
209 183 upgrade_op.print_optimisations()
210 184 upgrade_op.print_upgrade_actions()
211 185 upgrade_op.print_affected_revlogs()
@@ -225,7 +199,7 b' def upgraderepo('
225 199
226 200 # Else we're in the run=true case.
227 201 ui.write(_(b'upgrade will perform the following actions:\n\n'))
228 printrequirements()
202 upgrade_op.print_requirements()
229 203 upgrade_op.print_optimisations()
230 204 upgrade_op.print_upgrade_actions()
231 205 upgrade_op.print_affected_revlogs()
@@ -557,12 +557,32 b' def determineactions(repo, deficiencies,'
557 557 class UpgradeOperation(object):
558 558 """represent the work to be done during an upgrade"""
559 559
560 def __init__(self, ui, requirements, actions, revlogs_to_process):
560 def __init__(
561 self,
562 ui,
563 new_requirements,
564 current_requirements,
565 actions,
566 revlogs_to_process,
567 ):
561 568 self.ui = ui
562 self.requirements = requirements
569 self.new_requirements = new_requirements
570 self.current_requirements = current_requirements
563 571 self.actions = actions
564 572 self._actions_names = set([a.name for a in actions])
565 573 self.revlogs_to_process = revlogs_to_process
574 # requirements which will be added by the operation
575 self._added_requirements = (
576 self.new_requirements - self.current_requirements
577 )
578 # requirements which will be removed by the operation
579 self._removed_requirements = (
580 self.current_requirements - self.new_requirements
581 )
582 # requirements which will be preserved by the operation
583 self._preserved_requirements = (
584 self.current_requirements & self.new_requirements
585 )
566 586
567 587 def _write_labeled(self, l, label):
568 588 """
@@ -575,6 +595,27 b' class UpgradeOperation(object):'
575 595 self.ui.write(r, label=label)
576 596 first = False
577 597
598 def print_requirements(self):
599 self.ui.write(_(b'requirements\n'))
600 self.ui.write(_(b' preserved: '))
601 self._write_labeled(
602 self._preserved_requirements, "upgrade-repo.requirement.preserved"
603 )
604 self.ui.write((b'\n'))
605 if self._removed_requirements:
606 self.ui.write(_(b' removed: '))
607 self._write_labeled(
608 self._removed_requirements, "upgrade-repo.requirement.removed"
609 )
610 self.ui.write((b'\n'))
611 if self._added_requirements:
612 self.ui.write(_(b' added: '))
613 self._write_labeled(
614 self._added_requirements, "upgrade-repo.requirement.added"
615 )
616 self.ui.write((b'\n'))
617 self.ui.write(b'\n')
618
578 619 def print_optimisations(self):
579 620 optimisations = [a for a in self.actions if a.type == OPTIMISATION]
580 621 optimisations.sort(key=lambda a: a.name)
@@ -429,7 +429,7 b' def upgrade(ui, srcrepo, dstrepo, upgrad'
429 429 # The sorted() makes execution deterministic.
430 430 for p, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
431 431 if not _filterstorefile(
432 srcrepo, dstrepo, upgrade_op.requirements, p, kind, st
432 srcrepo, dstrepo, upgrade_op.new_requirements, p, kind, st
433 433 ):
434 434 continue
435 435
@@ -489,7 +489,7 b' def upgrade(ui, srcrepo, dstrepo, upgrad'
489 489 b'again\n'
490 490 )
491 491 )
492 scmutil.writereporequirements(srcrepo, upgrade_op.requirements)
492 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
493 493
494 494 # The lock file from the old store won't be removed because nothing has a
495 495 # reference to its new location. So clean it up manually. Alternatively, we
General Comments 0
You need to be logged in to leave comments. Login now