# Configuration file for migrating all Xebeo jobs to Bugzilla # # $Id: //info.ravenbrook.com/project/p4dti/branch/2001-08-07/migrate-bugzilla/code/replicator/configure_xebeo2.py#1 $ # # The Xebeo jobspec is currently the default Perforce jobspec. import configure_bugzilla import string # migrate_p(job). Decide whether or not a Perforce job should be # migrated to the defect tracker. It is applied to all Perforce jobs # during migration, and to any unreplicated Perforce job which changes # during replication. If it returns 1, the job will be migrated to # the defect tracker and thereafter will be replicated. If it returns # 0, the job will not be migrated to the defect tracker. def migrate_p(job): return 1 # pre_migrate_issue(config, bz, p4, job). Transform a migrating job # so that the replication field_map can be applied correctly. # # This is called when migrating a job from Perforce to the defect # tracker, before the field_map has been applied. It is passed the # job. The purpose of this function is to modify the job in such a # way that the field_map can be correctly applied. # # For instance, if the jobspec is to be changed after migration, the # field_map might not be able to translate values of fields which are # possible before migration but not afterwards. def pre_migrate_issue(config, bz, p4, job): job_status = job.get('Status','') if job_status == 'suspended': job['Status'] = 'closed' job['Resolution'] = 'later' elif job_status == 'open': job['Status'] = 'assigned' elif job_status == 'closed': job['Resolution'] = 'fixed' # migrate_issue(config, bz, p4, dict, job). Complete the translation # of a job into a new issue. # # This function is called when migrating a job from Perforce to the # defect tracker, after the field_map has been applied. It is passed # a dictionary representing the issue, which has been filled in by # applying the field_map, and the job record. The purpose of this # function is to fill in any other fields required or useful in the # defect tracker. # # For instance, Bugzilla requires 'short_desc' and 'reporter' both to # be set for a new bug. If they are not in the field_map, they must # be filled in by this function. # # There may be default values of various defect tracker fields; this # is the right place to set these. # # Fields may be added to the jobspec during initial migration for # later replication. These fields will appear in the field map, but # migrated jobs will not have values for them and so the the field map # translators will have been passed the empty string for them. This # is then a good place to fill in meaningful defaults for those # fields. # # Some fields may not be present in all jobs, for instance fields # which have been added to the jobspec after the creation of some # jobs. Such a field will be passed to the field map as an empty # string, and may be filled in here. def migrate_issue(config, bz, p4, dict, job): # we need a reporter field to create a bug. If we've installed a # P4DTI jobspec, we have the P4DTI-user field, so should translate # that. Otherwise, use the Assigned_To or User field. if not dict.has_key('reporter'): if job.has_key('P4DTI-user'): p4user = job['P4DTI-user'] elif job.has_key('Assigned_To'): p4user = job['Assigned_To'] else: p4user = job['User'] dict['reporter'] = config.user_translator.translate_1_to_0(p4user, bz, p4) # Set creation_ts to the 'Date' field, suitably translated. # (otherwise creation_ts gets now()). if (job.has_key('Date') and dict.get('creation_ts', '') == ''): dict['creation_ts'] = config.date_translator.translate_1_to_0(job['Date'], bz, p4) # If no summary, get short description from the first line of the # long description if dict.get('short_desc','') == '': short_desc = string.strip(job['Description']) newline_pos = string.find(short_desc, '\n') if newline_pos >= 0: short_desc = short_desc[:newline_pos] if short_desc == '': short_desc = 'No description' dict['short_desc'] = short_desc bugzilla_resolved_statuses = ['RESOLVED', 'VERIFIED', 'CLOSED'] # must fill in resolution for new jobs. if (dict.has_key('bug_status') and dict['bug_status'] in bugzilla_resolved_statuses and dict.get('resolution','') == ''): if job['Status'] == 'closed': dict['resolution'] = 'FIXED' elif job['Status'] == 'suspended': dict['resolution'] = 'LATER' # default values for various fields which Bugzilla requires but # the field map may not supply. for k,v in config.migrate_issue_defaults.items(): if dict.get(k,'') == '': dict[k] = v def configuration(config): default_jobspec, config = configure_bugzilla.configuration(config) config.pre_migrate_issue = pre_migrate_issue config.migrate_issue = migrate_issue config.migrate_p = migrate_p config.migrate_issue_defaults = { 'product': 'X-series', # new field in jobspec 'version': 'Pre-R1-Beta1', # new field in jobspec 'component': 'X-series', # new field in jobspec } # When a job is created by the replicator (because a new issue is # created in the defect tracker), should it use an # automatically-assigned Perforce jobname? config.use_perforce_jobnames = 1 # to which Bugzilla groups should migrated users belong? config.migrated_user_groups = ['editbugs', 'canconfirm'] # the Bugzilla password of a newly migrated user. config.migrated_user_password = 'p4dti-new' config.migrated_jobspec_description = default_jobspec return None, config