Merge lp:~brian-murray/cupstream2distro/bug-1460861 into lp:cupstream2distro

Proposed by Brian Murray
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 1358
Merged at revision: 1366
Proposed branch: lp:~brian-murray/cupstream2distro/bug-1460861
Merge into: lp:cupstream2distro
Diff against target: 90 lines (+16/-13)
2 files modified
cupstream2distro/branchhandling.py (+9/-0)
tests/unit/test_branchhandling.py (+7/-13)
To merge this branch: bzr merge lp:~brian-murray/cupstream2distro/bug-1460861
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) Approve
Review via email: mp+285115@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

1. Please drop ordereddict and just do the sorting when reading from the dict rather than sitting the input to the dict.

2. I'm not crazy about the implementation, i feel like it could be cleaner with something like this:

msgs = defaultdict(list)
for author, msg in authors.items():
    msgs[msg].append[author]
authors = {', '.join(ppl): msg for msg, ppl in msgs}

But also look into the called function, have it generate the dict correctly in the first place, rather than converting it and converting it back.

Revision history for this message
Robert Bruce Park (robru) wrote :

s/sitting/sorting/, sorry, on phone

Revision history for this message
Robert Bruce Park (robru) wrote :

Sorry, my comment about "called function" is wrong, this is the correct place to be working on, I'd just like to see a dict where the keys are messages and the values are lists of authors, rather than trying to munge the author list as a string and then deleting the old key every time you append.

Revision history for this message
Brian Murray (brian-murray) wrote :

messages can't be a key because those they are lists e.g.:

Traceback (most recent call last):
  File "/home/bdmurray/source-trees/cupstream2distro/trunk/tests/unit/test_branchhandling.py", line 403, in test_collect_author_with_launchpad_bot_commits
    self.assertEquals(self.branch.get_branch_commits(set()), ({
  File "/home/bdmurray/source-trees/cupstream2distro/trunk/cupstream2distro/branchhandling.py", line 307, in get_branch_commits
    msgs[msg].append(author)
TypeError: unhashable type: 'list'

Do you have any other ideas?

Revision history for this message
Robert Bruce Park (robru) wrote :

Ah, sorry. Make the list elements into the dict keys, so then something like:

by_msg = defaultdict(list)
for author, msgs in authors.items():
    for msg in msgs:
        by_msg[msg].append[author]
authors = {', '.join(sorted(ppl)): msg for msg, ppl in msgs}

The idea is that each individual commit message should only show up once but have a list of authors attached to it, rather than having authors show up once and have a list of messages attached to that.

1356. By Brian Murray

change how the author's dict is created per robru

1357. By Brian Murray

address reviewer feedback, stop using an OrderedDict

Revision history for this message
Robert Bruce Park (robru) wrote :

one comment inline.

Revision history for this message
Brian Murray (brian-murray) wrote :

Its not clear to me what you are looking for now. Could you elaborate?

On Mon, Feb 08, 2016 at 07:22:06PM -0000, Robert Bruce Park wrote:
> one comment inline.
>
> Diff comments:
>
> >
> > === modified file 'tests/unit/test_branchhandling.py'
> > --- tests/unit/test_branchhandling.py 2015-12-04 05:58:26 +0000
> > +++ tests/unit/test_branchhandling.py 2016-02-08 19:03:59 +0000
> > @@ -330,22 +328,24 @@
> > def test_collect_author_commits_regular(self):
> > """Collect author commits and bugs for a normal bzr log."""
> > self.mock_diff_since_newest_tag('classiclogdiff')
> > - self.assertEquals(self.branch.get_branch_commits(set()), ({
> > - 'Sebastien Bacher': [
> > - "Use '%s:' string for preview hints, rather than just "
> > - "appending ':'. (LP: #1074038)"
> > - ], 'Brandon Schaefer': [
> > + commits = self.branch.get_branch_commits(set())
> > + commits = sorted(commits.items())
> > + self.assertEquals(commits, ([
> > + ('Andrea Azzarone', [
> > + 'Disable detail view for webapp icons. (LP: #1169340)'
> > + ]), ('Brandon Schaefer, Marco Trevisan (Treviño)', [
>
> Please changing this list of tuples back into a dictionary, will avoid the sorting issues with trying to test against the value of "commits.items()"
>
> > 'EdgeBarrierController: add multiple types of subscriber '
> > 'results, fix edges on autohide (LP: #1064945)'
> > - ], 'Marco Trevisan (Treviño)': [
> > - 'Simulating direct commit to trunk',
> > - 'EdgeBarrierController: add multiple types of subscriber '
> > - 'results, fix edges on autohide (LP: #1064945)',
> > + ]), ('Marco Trevisan (Treviño)', [
> > 'IconRenderer: preprocess an icon if its emblem has been '
> > 'shown/hidden (LP: #1171476, #1171663)',
> > + 'Simulating direct commit to trunk',
> > "UnityWindow: don't draw the panel shadow above a "
> > - "fullscreen window. (LP: #1171934)"
> > - ], "Łukasz 'sil2100' Zemczak": [
> > + "fullscreen window. (LP: #1171934)",
> > + ]), ('Sebastien Bacher', [
> > + "Use '%s:' string for preview hints, rather than just "
> > + "appending ':'. (LP: #1074038)",
> > + ]), ("Łukasz 'sil2100' Zemczak", [
> > 'Now that we\'re using the new HUD, there have been some '
> > 'changes that typically cause test_hud tests to fail. '
> > 'Fix the tests to fit the new model. The first one is '
>
>
> --
> https://code.launchpad.net/~brian-murray/cupstream2distro/bug-1460861/+merge/285115
> You are the owner of lp:~brian-murray/cupstream2distro/bug-1460861.
>
--
Brian Murray

Revision history for this message
Robert Bruce Park (robru) wrote :

Look at your diff in the test suite. There are two changes happening:

1) you made the desired change of 'Author 1, Author 2' in the author names.

2) You changed a perfectly good dictionary into this bizarre list of tuples and it's significantly more difficult to read. so please change this:

+ commits = self.branch.get_branch_commits(set())
+ commits = sorted(commits.items())
+ self.assertEquals(commits, ([
+ ('Andrea Azzarone', [
+ 'Disable detail view for webapp icons. (LP: #1169340)'

Back to this:

- self.assertEquals(self.branch.get_branch_commits(set()), ({
- 'Sebastien Bacher': [
- "Use '%s:' string for preview hints, rather than just "
- "appending ':'. (LP: #1074038)"

The diff will guide you. Just eliminate all the changes that aren't string changes.

Revision history for this message
Robert Bruce Park (robru) wrote :

one more comment inline

Revision history for this message
Brian Murray (brian-murray) wrote :

On Mon, Feb 08, 2016 at 09:40:28PM -0000, Robert Bruce Park wrote:
> Look at your diff in the test suite. There are two changes happening:
>
> 1) you made the desired change of 'Author 1, Author 2' in the author names.
>
> 2) You changed a perfectly good dictionary into this bizarre list of tuples and it's significantly more difficult to read. so please change this:
>
> + commits = self.branch.get_branch_commits(set())
> + commits = sorted(commits.items())
> + self.assertEquals(commits, ([
> + ('Andrea Azzarone', [
> + 'Disable detail view for webapp icons. (LP: #1169340)'
>
> Back to this:
>
> - self.assertEquals(self.branch.get_branch_commits(set()), ({
> - 'Sebastien Bacher': [
> - "Use '%s:' string for preview hints, rather than just "
> - "appending ':'. (LP: #1074038)"
>
> The diff will guide you. Just eliminate all the changes that aren't string changes.

The tests were behaving erratically unless the data was sorted in this
way.

--
Brian Murray

Revision history for this message
Robert Bruce Park (robru) wrote :

> The tests were behaving erratically unless the data was sorted in this
> way.

That's because you were trying to compare a dict to an ordereddict. I'm asking you to compare an unordered dict to an unordered dict, the order will not matter.

1358. By Brian Murray

restore tests to their original version more or less

Revision history for this message
Brian Murray (brian-murray) wrote :

I'm pretty sure I had removed the OrderedDict and was still having issues with things be out of order, perhaps the failure was really with the msgs for a specific author. Regardless, I've restored the tests now.

Revision history for this message
Robert Bruce Park (robru) wrote :

Great, thanks, diff looks way nicer, will merge soon.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cupstream2distro/branchhandling.py'
2--- cupstream2distro/branchhandling.py 2016-02-08 19:46:41 +0000
3+++ cupstream2distro/branchhandling.py 2016-02-09 20:31:59 +0000
4@@ -273,6 +273,7 @@
5 :returns: {'Author': ['Commit 1', 'Commit 2']}
6 """
7 authors = defaultdict(list)
8+ by_msgs = defaultdict(list)
9 data = defaultdict(str)
10 for data in parse_bzr_log(self.diff_since_newest_branch_tag()):
11 msg = data['message:'].rsplit('Approved by', 1)[0].strip()
12@@ -287,6 +288,14 @@
13 author = author.split(' <')[0].strip()
14 if not ignored(author):
15 authors[author].append(msg + format_bugs(bugs))
16+ for author, msgs in authors.items():
17+ for msg in msgs:
18+ by_msgs[msg].append(author)
19+ authors.clear()
20+ for msg, ppl in by_msgs.items():
21+ authors[', '.join(sorted(ppl))].append(msg)
22+ for author, msgs in authors.items():
23+ authors[author] = sorted(msgs)
24 return authors
25
26 def missing_branch_commits(self, branch, target):
27
28=== modified file 'tests/unit/test_branchhandling.py'
29--- tests/unit/test_branchhandling.py 2016-02-08 19:46:41 +0000
30+++ tests/unit/test_branchhandling.py 2016-02-09 20:31:59 +0000
31@@ -310,10 +310,8 @@
32 """Collect author commits and bugs when the msg starts with '-'."""
33 self.mock_diff_since_newest_tag('withdashlogdiff')
34 self.assertEquals(self.branch.get_branch_commits(set()), ({
35- 'Diego Sarmentero': [
36- 'Update download manager API (BUG: #1224538). (LP: #1224538)',
37- ], 'Manuel de la Pena': [
38- 'Update download manager API (BUG: #1224538). (LP: #1224538)',
39+ 'Diego Sarmentero, Manuel de la Pena': [
40+ 'Update download manager API (BUG: #1224538). (LP: #1224538)'
41 ]}))
42
43 def test_collect_author_commits_starting_with_star(self):
44@@ -334,15 +332,13 @@
45 'Sebastien Bacher': [
46 "Use '%s:' string for preview hints, rather than just "
47 "appending ':'. (LP: #1074038)"
48- ], 'Brandon Schaefer': [
49+ ], 'Brandon Schaefer, Marco Trevisan (Treviño)': [
50 'EdgeBarrierController: add multiple types of subscriber '
51 'results, fix edges on autohide (LP: #1064945)'
52 ], 'Marco Trevisan (Treviño)': [
53- 'Simulating direct commit to trunk',
54- 'EdgeBarrierController: add multiple types of subscriber '
55- 'results, fix edges on autohide (LP: #1064945)',
56 'IconRenderer: preprocess an icon if its emblem has been '
57 'shown/hidden (LP: #1171476, #1171663)',
58+ 'Simulating direct commit to trunk',
59 "UnityWindow: don't draw the panel shadow above a "
60 "fullscreen window. (LP: #1171934)"
61 ], "Łukasz 'sil2100' Zemczak": [
62@@ -367,9 +363,9 @@
63 "Use '%s:' string for preview hints, rather than just "
64 "appending ':'. (LP: #1074038)"
65 ], 'Marco Trevisan (Treviño)': [
66- 'Simulating direct commit to trunk',
67 'IconRenderer: preprocess an icon if its emblem has been '
68 'shown/hidden (LP: #1171476, #1171663)',
69+ 'Simulating direct commit to trunk',
70 "UnityWindow: don't draw the panel shadow above a "
71 'fullscreen window. (LP: #1171934)'
72 ], "Łukasz 'sil2100' Zemczak": [
73@@ -407,15 +403,13 @@
74 'Sebastien Bacher': [
75 "Use '%s:' string for preview hints, rather than just "
76 "appending ':'. (LP: #1074038)"
77- ], 'Brandon Schaefer': [
78+ ], 'Brandon Schaefer, Marco Trevisan (Treviño)': [
79 'EdgeBarrierController: add multiple types of subscriber '
80 'results, fix edges on autohide (LP: #1064945)'
81 ], 'Marco Trevisan (Treviño)': [
82- 'Simulating direct commit to trunk',
83- 'EdgeBarrierController: add multiple types of subscriber '
84- 'results, fix edges on autohide (LP: #1064945)',
85 'IconRenderer: preprocess an icon if its emblem has been '
86 'shown/hidden (LP: #1171476, #1171663)',
87+ 'Simulating direct commit to trunk',
88 "UnityWindow: don't draw the panel shadow above a "
89 'fullscreen window. (LP: #1171934)'
90 ], "Łukasz 'sil2100' Zemczak": [

Subscribers

People subscribed via source and target branches

to all changes: