# Configuration file for migrating all Xebeo jobs to Bugzilla # # $Id: //info.ravenbrook.com/project/p4dti/branch/2001-04-20/migrate-bugzilla/code/replicator/configure_xebeo2.py#5 $ # # The Xebeo jobspec is currently the default Perforce jobspec. import configure_bugzilla import string def migrate_p(job): return 1 defaults = { 'product': 'X-series', # new field in jobspec 'version': 'Pre-R1-Beta1', # new field in jobspec 'component': 'X-series', # new field in jobspec } # This function 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 safely applied. # # For instance, if the jobspec is to be changed after migration, the # field_map may not know how 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' # 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. The purpose of this function is then 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 (even if they are not replicated). # # There may also be default values of various defect tracker fields; # this is the right place to add these. # # Also, during initial migration, fields may be added to the jobspec # for later replication with defect tracker fields. These fields will # appear in the field map, but migrated jobs will not have values for # them and so the field map translators will be passed the empty # string for them. This is then a good place to fill in meaningful # defaults for those fields. # # For Xebeo, such fields are 'product', 'component', 'version', and # 'short_desc'. # # Also during initial migration, one must consider any jobspec fields # which are not present in all jobs, even if they are 'required' in # the jobspec. For instance, a field may have been added to the # jobspec after some jobs had already been created. Such a field will # be passed to the field map as an empty string, and may be filled in # here. # # For Xebeo, there are no such fields. 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, we have to use the User field. if not dict.has_key('reporter'): if job.has_key('P4DTI-user'): p4user = job['P4DTI-user'] 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', '') == ''): print "setting creation_ts from Date" 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'] = 'CLOSED' elif job['Status'] == 'suspended': dict['resolution'] = 'LATER' # default values for various fields which Bugzilla requires but # the field map may not supply. Defined in 'defaults' above. for k,v in defaults.items(): if dict.get(k,'') == '': dict[k] = v def configuration(config): default_jobspec, config = configure_bugzilla.configuration(config) # function applied before replication to correct a job issue # (e.g. by filling in additional fields) before giving the new # issue to the defect tracker config.pre_migrate_issue = pre_migrate_issue # function applied after replication to correct an issue (e.g. by # filling in additional fields) before giving the new issue to # the defect tracker config.migrate_issue = migrate_issue # function to apply to a job to decide whether or not to # migrate it to the defect tracker. config.migrate_p = migrate_p # 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 config.job_owner_field = 'User' return None, config