Skip to content

Commit

Permalink
[copy_duplicate_info] Drop disabled code (#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaibmujahid authored Sep 23, 2023
1 parent 8bfc159 commit 8e8587c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 75 deletions.
75 changes: 6 additions & 69 deletions bugbot/rules/copy_duplicate_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ def __init__(self):
def description(self):
return "Bugs which are DUPLICATE and some info haven't been moved"

def has_product_component(self):
return True

def set_autofix(self, bugs, dups, signatures, pcs):
def set_autofix(self, bugs, dups, signatures):
for bugid, missed_sgns in signatures.items():
sgns = dups[bugid]["signature"]
sgns = utils.add_signatures(sgns, missed_sgns)
Expand All @@ -28,43 +25,6 @@ def set_autofix(self, bugs, dups, signatures, pcs):
"comment": {"body": "Copying crash signatures from duplicate bugs."},
}

for bugid, pc in pcs.items():
if bugid in self.autofix_data:
self.autofix_data[bugid].update(pc)
else:
self.autofix_data[bugid] = pc

def get_fixed_bugs(self, bugs, dups, signatures, pcs):
res = {}
for bugid in signatures.keys():
res[bugid] = info = dups[bugid]
info["update_signature"] = "Yes"

for bugid in pcs.keys():
if bugid in res:
res[bugid]["update_pc"] = "Yes"
else:
res[bugid] = info = bugs[bugid]
info["update_pc"] = "Yes"

for info in res.values():
if "update_pc" not in info:
info["update_pc"] = "No"
if "update_signature" not in info:
info["update_signature"] = "No"

return res

def columns(self):
return ["id", "summary", "update_signature", "update_pc"]

def sort_columns(self):
return lambda p: (
0 if p[2] == "Yes" else 1,
0 if p[3] == "Yes" else 1,
-int(p[0]),
)

def get_autofix_change(self):
return self.autofix_data

Expand All @@ -75,18 +35,12 @@ def handle_bug(self, bug, data):
"summary": self.get_summary(bug),
"signature": bug.get("cf_crash_signature", ""),
"dupe": str(bug["dupe_of"]),
"product": bug["product"],
"component": bug["component"],
"version": bug["version"],
"is_private": bool(bug["groups"]),
}
return bug

def get_dups(self, bugs):
def handler(bug, data):
if bug["product"] in self.get_config("products"):
self.handle_bug(bug, data)

bugids = [info["dupe"] for info in bugs.values()]
data = {}

Expand All @@ -95,14 +49,12 @@ def handler(bug, data):
include_fields=[
"cf_crash_signature",
"dupe_of",
"product",
"component",
"id",
"summary",
"groups",
"version",
],
bughandler=handler,
bughandler=self.handle_bug,
bugdata=data,
).get_data().wait()

Expand All @@ -112,7 +64,6 @@ def compare(self, bugs, dups):
# each bug in bugs is the dup of one in dups
# so the characteristics of this bug should be in the dup
signatures = {}
pcs = {}
for bugid, info in bugs.items():
dupid = info["dupe"]
if dupid not in dups:
Expand All @@ -129,20 +80,7 @@ def compare(self, bugs, dups):
if not bs.issubset(ds):
signatures[dupid] = bs - ds

pc = {}
for x in ["product", "component"]:
if info[x] != dup[x]:
pc[x] = dup[x]
if pc:
# when we change the product, we change the version too
# to avoid incompatible version in the new product
if "product" in pc and info["version"] != dup["version"]:
pc["version"] = dup["version"]
pcs[bugid] = pc

# Don't move product/component for now
# return signatures, pcs
return signatures, {}
return signatures

def get_bz_params(self, date):
start_date, end_date = self.get_dates(date)
Expand All @@ -160,12 +98,11 @@ def get_bz_params(self, date):
def get_bugs(self, date="today", bug_ids=[]):
bugs = super(CopyDuplicateInfo, self).get_bugs(date=date, bug_ids=bug_ids)
dups = self.get_dups(bugs)
signatures, pcs = self.compare(bugs, dups)
signatures = self.compare(bugs, dups)

self.set_autofix(bugs, dups, signatures, pcs)
bugs = self.get_fixed_bugs(bugs, dups, signatures, pcs)
self.set_autofix(bugs, dups, signatures)

return bugs
return {bugid: dups[bugid] for bugid in signatures}


if __name__ == "__main__":
Expand Down
8 changes: 2 additions & 6 deletions templates/copy_duplicate_info.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
<p>
The following {{ plural('bug has', data, pword='bugs have') }} been fixed as DUPLICATE and some information haven't been moved:
The following {{ plural('bug has', data, pword='bugs have') }} been fixed as DUPLICATE and some crash signatures haven't been moved:
</p>
<table {{ table_attrs }}>
<thead>
<tr>
<th>Bug</th>
<th>Summary</th>
<th>Update signature</th>
<th>Update product::component</th>
</tr>
</thead>
<tbody>
{% for i, (bugid, summary, update_signature, update_pc) in enumerate(data) -%}
{% for i, (bugid, summary) in enumerate(data) -%}
<tr {% if i % 2 == 0 %}bgcolor="#E0E0E0"
{% endif -%}
>
<td>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id={{ bugid }}">{{ bugid }}</a>
</td>
<td>{{ summary | e }}</td>
<td>{{ update_signature }}</td>
<td>{{ update_pc }}</td>
</tr>
{% endfor -%}
</tbody>
Expand Down

0 comments on commit 8e8587c

Please sign in to comment.