aboutsummaryrefslogtreecommitdiffstats
path: root/.be/bugs/51930348-9ccc-4165-af41-6c7450de050e/comments/d304f93b-faf2-477e-9ff8-c77e301fd9f9/body
blob: 34d37e532293d6c077bba3e9bcba9d6c8d47aef4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Added libbe/upgrade.py to handle upgrading on-disk bugdirs.

When upgrade.BUGDIR_DISK_VERSION changes, a series of Updater
classes handle the upgrade.  For example, if 
  BUGDIR_DISK_VERSIONS = ["v1", "v2", "v3"]
and the on-disk version is "v1", you should have defined classes
  class Upgrade_1_to_2 (Upgrader):
      initial_version = "v1"
      final_version = "v2"
      def _upgrade():
          ....
  class Upgrade_2_to_3 (Upgrader):
      initial_version = "v2"
      final_version = "v3"
      def _upgrade():
          ....
and added them to upgraders:
  upgraders = [Upgrade_1_to_2, Upgrade_2_to_3]
If the on-disk version is v2, then only Upgrade_2_to_3.upgrade() is
run.  If the on-disk version is v1, then Upgrade_1_to_2.upgrade() is
run, followed by Upgrade_2_to_3.upgrade().

You can optionally define shortcut upgrades (e.g. Upgrade_1_to_3) for
efficiency or to avoid data loss.

This upgrade occurs during BugDir.load(), which is called by
BugDir.__init__(from_disk=True), before any processing of the on-disk
data except for the access of .be/version to determine if an upgrade
was necessary.