def storage_format_upgrade(upgrade_name, upgrade_from, upgrade_to):
    def decorator(the_upgrade):
        @functools.wraps(the_upgrade)
        def wrapper(repo_path):
            eg = EasyGit.open_repo(repo_path)

            if 'features' not in eg.root:
                upgrade_log.info('Creating "features" blob for repository %r',
                         repo_path)
                b = eg.root.new_blob('features')
                b.data = '{}'
            features = FeatureBlob(eg.root['features'])

            for name, value in upgrade_from.iteritems():
                if features.get(name, None) is not value:
                    upgrade_log.debug('Skipping upgrade %r on repository %r, '
                              'feature %r is not %r',
                              upgrade_name, repo_path, name, value)
                    return

            upgrade_log.info('Starting upgrade %r on repository %r',
                     upgrade_name, repo_path)
            the_upgrade(eg)

            upgrade_log.debug('Writing features for upgrade %r', upgrade_name)
            for name, value in upgrade_to.iteritems():
                features[name] = value

            message = "Update script %r" % upgrade_name
            eg.commit(GitStorage.commit_author, message,
                      [eg.get_head_id('master')])
            upgrade_log.info('Finished upgrade %r on repository %r',
                     upgrade_name, repo_path)

        return wrapper

    return decorator
dataset/ETHPy150Open mgax/SpaghettiFS/spaghettifs/storage.py/storage_format_upgrade/original