def bzbug_ref_translate(text): mentioned_bugs = find_bug_refs(text) phabrefs = {} for b in mentioned_bugs: bugint = re.search('\d+', b).group(0) reft = phabdb.reference_ticket('%s%s' % (bzlib.prepend, bugint)) if reft: phabrefs[b] = reft refdict = {k: v[0] for k, v in phabrefs.iteritems() if v is not None} taskid = lambda x: phabdb.get_task_id_by_phid(x) newrefs = {k: "T%s" % (taskid(v),) for k, v in refdict.iteritems()} return replace_bug_refs(text, newrefs)
def remove_issue_by_bugid(bugid, ref): log("Removing issue by reference %s%s" % (ref, bugid)) taskphid = phabdb.reference_ticket("%s%s" % (ref, bugid)) log("Removing issue by taskphid %s" % (taskphid,)) if len(taskphid) < 1: return 'no task phid found to remove' issueid = phabdb.get_task_id_by_phid(taskphid[0]) notice("!Removing issue T%s!" % (issueid,)) out = '' out += destroy_issue(issueid) out += str(phabdb.remove_reference("%s%s" % (ref, bugid))) out += str(phabdb.reference_ticket("%s%s" % (ref, bugid))) return out