Merge lp:~cjwatson/launchpad/bmp-remove-old-comment-threading into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18628
Proposed branch: lp:~cjwatson/launchpad/bmp-remove-old-comment-threading
Merge into: lp:launchpad
Diff against target: 177 lines (+3/-112)
4 files modified
lib/lp/code/browser/branchmergeproposal.py (+0/-22)
lib/lp/services/messages/interfaces/message.py (+1/-22)
lib/lp/services/messages/model/message.py (+1/-37)
lib/lp/services/messages/tests/test_message.py (+1/-31)
To merge this branch: bzr merge lp:~cjwatson/launchpad/bmp-remove-old-comment-threading
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+344197@code.launchpad.net

Commit message

Remove BranchMergeProposalView.comments and the underlying message threading support.

Description of the change

It's superseded by BranchMergeProposalView.conversation.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
2--- lib/lp/code/browser/branchmergeproposal.py 2018-03-16 21:20:00 +0000
3+++ lib/lp/code/browser/branchmergeproposal.py 2018-04-24 23:07:17 +0000
4@@ -102,7 +102,6 @@
5 from lp.services.config import config
6 from lp.services.features import getFeatureFlag
7 from lp.services.librarian.interfaces.client import LibrarianServerError
8-from lp.services.messages.interfaces.message import IMessageSet
9 from lp.services.propertycache import (
10 cachedproperty,
11 get_property_cache,
12@@ -706,27 +705,6 @@
13 comment).previewdiff_id = relations.get(comment.id)
14
15 @property
16- def comments(self):
17- """Return comments associated with this proposal, plus styling info.
18-
19- Comments are in threaded order, and the style indicates indenting
20- for use with threads.
21- """
22- message_to_comment = {}
23- messages = []
24- for comment in self.context.all_comments:
25- message_to_comment[comment.message] = comment
26- messages.append(comment.message)
27- message_set = getUtility(IMessageSet)
28- threads = message_set.threadMessages(messages)
29- result = []
30- for depth, message in message_set.flattenThreads(threads):
31- comment = message_to_comment[message]
32- style = 'margin-left: %dem;' % (2 * depth)
33- result.append(dict(style=style, comment=comment))
34- return result
35-
36- @property
37 def label(self):
38 return "Merge %s into %s" % (
39 self.context.merge_source.identity,
40
41=== modified file 'lib/lp/services/messages/interfaces/message.py'
42--- lib/lp/services/messages/interfaces/message.py 2015-07-09 20:06:17 +0000
43+++ lib/lp/services/messages/interfaces/message.py 2018-04-24 23:07:17 +0000
44@@ -1,4 +1,4 @@
45-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
46+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
47 # GNU Affero General Public License version 3 (see the file LICENSE).
48
49 __metaclass__ = type
50@@ -165,27 +165,6 @@
51 * InvalidEmailMessage
52 """
53
54- def threadMessages(messages):
55- """Return a threaded version of supplied message list.
56-
57- Return value is a recursive list structure.
58- Each parent entry in the top-level list is a tuple of
59- (parent, children), where children is a list of parents. (Parents
60- may be childless.)
61-
62- Example:
63- [(parent, [(child1, [(grandchild1, [])]), (child2, [])])]
64- """
65-
66- def flattenThreads(threaded_messages):
67- """Convert threaded messages into a flat, indented form.
68-
69- Take a thread (in the form produced by threadMessages) and
70- iterate through a series of (depth, message) tuples. The ordering
71- will match that implied by the input structure, with all replies
72- to a message appearing after that message.
73- """
74-
75
76 class IIndexedMessage(Interface):
77 """An `IMessage` decorated with its index and context."""
78
79=== modified file 'lib/lp/services/messages/model/message.py'
80--- lib/lp/services/messages/model/message.py 2015-07-08 16:05:11 +0000
81+++ lib/lp/services/messages/model/message.py 2018-04-24 23:07:17 +0000
82@@ -1,4 +1,4 @@
83-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
84+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
85 # GNU Affero General Public License version 3 (see the file LICENSE).
86
87 __metaclass__ = type
88@@ -483,42 +483,6 @@
89 Store.of(message).flush()
90 return message
91
92- @staticmethod
93- def _parentToChild(messages):
94- """Return a mapping from parent to child and list of root messages."""
95- result = {}
96- roots = []
97- for message in messages:
98- if message.parent is None:
99- roots.append(message)
100- else:
101- result.setdefault(message.parent, []).append(message)
102- result.setdefault(message, [])
103- return result, roots
104-
105- @classmethod
106- def threadMessages(klass, messages):
107- """See `IMessageSet`."""
108- result, roots = klass._parentToChild(messages)
109-
110- def get_children(node):
111- children = []
112- for child in result[node]:
113- children.append((child, get_children(child)))
114- return children
115- threads = []
116- for root in roots:
117- threads.append((root, get_children(root)))
118- return threads
119-
120- @classmethod
121- def flattenThreads(klass, threaded_messages, _depth=0):
122- """See `IMessageSet`."""
123- for message, children in threaded_messages:
124- yield (_depth, message)
125- for depth, message in klass.flattenThreads(children, _depth + 1):
126- yield depth, message
127-
128
129 @implementer(IMessageChunk)
130 class MessageChunk(SQLBase):
131
132=== modified file 'lib/lp/services/messages/tests/test_message.py'
133--- lib/lp/services/messages/tests/test_message.py 2014-01-30 15:04:06 +0000
134+++ lib/lp/services/messages/tests/test_message.py 2018-04-24 23:07:17 +0000
135@@ -1,4 +1,4 @@
136-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
137+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
138 # GNU Affero General Public License version 3 (see the file LICENSE).
139
140 __metaclass__ = type
141@@ -42,36 +42,6 @@
142 message4 = self.factory.makeMessage(parent=message2)
143 return (message1, message2, message3, message4)
144
145- def test_parentToChild(self):
146- """Test MessageSet._parentToChild."""
147- messages = self.createTestMessages()
148- message1, message2, message3, message4 = messages
149- expected = {
150- message1: [message2, message3],
151- message2: [message4],
152- message3: [], message4: []}
153- result, roots = MessageSet._parentToChild(messages)
154- self.assertEqual(expected, result)
155- self.assertEqual([message1], roots)
156-
157- def test_threadMessages(self):
158- """Test MessageSet.threadMessages."""
159- messages = self.createTestMessages()
160- message1, message2, message3, message4 = messages
161- threads = MessageSet.threadMessages(messages)
162- self.assertEqual(
163- [(message1, [(message2, [(message4, [])]), (message3, [])])],
164- threads)
165-
166- def test_flattenThreads(self):
167- """Test MessageSet.flattenThreads."""
168- messages = self.createTestMessages()
169- message1, message2, message3, message4 = messages
170- threads = MessageSet.threadMessages(messages)
171- flattened = list(MessageSet.flattenThreads(threads))
172- expected = [(0, message1), (1, message2), (2, message4), (1, message3)]
173- self.assertEqual(expected, flattened)
174-
175 def _makeMessageWithAttachment(self, filename='review.diff'):
176 sender = self.factory.makePerson()
177 msg = MIMEMultipart()