Open Bug 1173560 Opened 9 years ago Updated 6 years ago

De-duplicate bug numbers in the newly added metadata shown on hgweb

Categories

(Developer Services :: Mercurial: hg.mozilla.org, defect)

defect
Not set
normal

Tracking

(Not tracked)

REOPENED

People

(Reporter: KWierso, Unassigned)

References

Details

Attachments

(2 files)

The metadata shows the same bug number multiple times if it finds multiple instances in the commit information (eg https://hg.mozilla.org/integration/b2g-inbound/rev/dbf3b1ad8240 shows "bugs: 30507, 1169861, 1169861, 1169861")

It'd be nice if it would only list each bug once no matter how many times it finds it in the commit.
I think this is all that would be needed?
Assignee: nobody → wkocher
Attachment #8620646 - Flags: review?(gps)
Or should this be on the commit parser's side?
Comment on attachment 8620646 [details] [diff] [review]
Pass the list of bugs through set() to remove duplicates.

Yes, this is all that is needed. Although commit message order may get lost. I don't think we care though.
Attachment #8620646 - Flags: review?(gps) → review+
Hrm, it's still listing duplicates. Do I need to get rid of the list() part to make sure set() remains a unique list?
Flags: needinfo?(gps)
Look at the line below. Why we're making two calls to parse bugs, I don't know. How I missed this in code review, I can't believe.

This is why you write tests.
Status: RESOLVED → REOPENED
Flags: needinfo?(gps)
Resolution: FIXED → ---
Bug 1173560 - Really remove duplicate bug numbers from the metadata before it gets displayed.

For some reason, there were two attempts to parse bugs, but it looks like only the second attempt is actually used for anything, while my first patch only changed the first attempt.

This version removes that first, apparently unused parse, and removes the duplicates from the actually-used parse.
^ is totally untested by me. Don't know if calling set() like that changes things too much beyond what hg expects. I'm also unsure exactly how to test it. Please don't let me land this without someone making sure it doesn't break everything. :)
Comment on attachment 8621242 [details]
MozReview Request: Bug 1173560 - Really remove duplicate bug numbers from the metadata before it gets displayed.

https://reviewboard.mozilla.org/r/10925/#review9855

::: hgext/hgmo/__init__.py:33
(Diff revision 1)
> +    d['bugs'] = set(d['bugs']);

We prefer to keep the ordering of this list. Plus, doing a set() on a list of dicts doesn't work because set() works by looking at hash(<object>) and hash({}) doesn't work. I suspect you would have discovered this had you ran the tests:

  $ ./run-tests hgext/hgmo
  
You'll want to introduce a new variable to track which bugs have been seen. e.g.:

  d['bugs'] = []
  seen_bugs = set()
  for bug in ...:
      if bug in seen_bugs:
          continue
      seen_bugs.add(bug)
      d['bugs'].append({...})

::: hgext/hgmo/__init__.py:41
(Diff revision 1)
> +    d['reviewers'] = set(d['reviewers']);

Ditto.
Attachment #8621242 - Flags: review?(gps)
QA Contact: hwine → klibby
Assignee: kwierso → nobody
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: