Merge ~pappacena/launchpad:bugtrackercompo-matching-interface into launchpad:master

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: c780af85696c496c2c6cfaae638117e4ba5c1194
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:bugtrackercompo-matching-interface
Merge into: launchpad:master
Diff against target: 140 lines (+19/-19)
4 files modified
lib/lp/bugs/browser/bugtracker.py (+12/-12)
lib/lp/bugs/browser/tests/test_bugtracker_component.py (+3/-3)
lib/lp/bugs/interfaces/bugtracker.py (+2/-2)
lib/lp/bugs/model/bugtracker.py (+2/-2)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+377194@code.launchpad.net

Commit message

Renaming source_package_name attribute on BugTrackerComponent to match interface's naming.

Description of the change

Used pycharm renaming tool, and it didn't find any other usage of this attribute. The lp.bugs* seems to be running fine too.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

I see your initial approach was to rename the attribute in the interface instead, but then you reverted that. Could you explain why you decided not to take that approach? Since we already have things like IBugTrackerComponent.distro_source_package and IBugTrackerComponent.component_group, and since the database column name is underscore-separated, the underscore-separated form seems to be a better fit here.

review: Needs Information
1e6a147... by Thiago F. Pappacena

Merge branch 'master' into bugtrackercompo-matching-interface

Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

cjwatson, I agree that ideally we should change the attributes to underscore-separed style for consistency, but this would break API compatibility (IBugTrackerComponent is exported at webservice.py).

Wouldn't it be a problem?

Revision history for this message
Colin Watson (cjwatson) wrote :

The sourcepackagename attribute of IBugTrackerComponent isn't exported; only those attributes with exported() or methods with one of the @export_* decorators are exported.

(If it had been exported, then you could maintain compatibility using exported_as='sourcepackagename'; but that isn't necessary here.)

Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Ah, right! I'm aware of the exported* now, but I didn't know about it when I opened the MP.

I'll rename it at interface level now.

c780af8... by Thiago F. Pappacena

renaming BugTrackerComponent.sourcepackagename to use underscores

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/browser/bugtracker.py b/lib/lp/bugs/browser/bugtracker.py
2index 25e8510..88ca12b 100644
3--- a/lib/lp/bugs/browser/bugtracker.py
4+++ b/lib/lp/bugs/browser/bugtracker.py
5@@ -1,4 +1,4 @@
6-# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
7+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """Bug tracker views."""
11@@ -466,8 +466,8 @@ class BugTrackerEditComponentView(LaunchpadEditFormView):
12 linked to source packages in the Ubuntu distribution.
13 """
14 schema = IBugTrackerComponent
15- custom_widget_sourcepackagename = UbuntuSourcePackageNameWidget
16- field_names = ['sourcepackagename']
17+ custom_widget_source_package_name = UbuntuSourcePackageNameWidget
18+ field_names = ['source_package_name']
19 page_title = 'Link component'
20
21 @property
22@@ -479,10 +479,10 @@ class BugTrackerEditComponentView(LaunchpadEditFormView):
23 @property
24 def initial_values(self):
25 """See `LaunchpadFormView.`"""
26- field_values = dict(sourcepackagename='')
27+ field_values = dict(source_package_name='')
28 dsp = self.context.distro_source_package
29 if dsp is not None:
30- field_values['sourcepackagename'] = dsp.name
31+ field_values['source_package_name'] = dsp.name
32 return field_values
33
34 @property
35@@ -498,24 +498,24 @@ class BugTrackerEditComponentView(LaunchpadEditFormView):
36 look it up in Ubuntu to retrieve the distro_source_package
37 object, and link it to this component.
38 """
39- sourcepackagename = data['sourcepackagename']
40- distribution = self.widgets['sourcepackagename'].getDistribution()
41- dsp = distribution.getSourcePackage(sourcepackagename)
42+ source_package_name = data['source_package_name']
43+ distribution = self.widgets['source_package_name'].getDistribution()
44+ dsp = distribution.getSourcePackage(source_package_name)
45 bug_tracker = self.context.component_group.bug_tracker
46 # Has this source package already been assigned to a component?
47 component = bug_tracker.getRemoteComponentForDistroSourcePackageName(
48- distribution, sourcepackagename)
49+ distribution, source_package_name)
50 if component is not None:
51 self.request.response.addNotification(
52 "The %s source package is already linked to %s:%s in %s." % (
53- sourcepackagename.name,
54+ source_package_name.name,
55 component.component_group.name,
56 component.name, distribution.name))
57 return
58 # The submitted component can be linked to the distro source package.
59 component = context or self.context
60 component.distro_source_package = dsp
61- if sourcepackagename is None:
62+ if source_package_name is None:
63 self.request.response.addNotification(
64 "%s:%s is now unlinked." % (
65 component.component_group.name, component.name))
66@@ -523,7 +523,7 @@ class BugTrackerEditComponentView(LaunchpadEditFormView):
67 self.request.response.addNotification(
68 "%s:%s is now linked to the %s source package in %s." % (
69 component.component_group.name, component.name,
70- sourcepackagename.name, distribution.name))
71+ source_package_name.name, distribution.name))
72
73 @action('Save Changes', name='save')
74 def save_action(self, action, data):
75diff --git a/lib/lp/bugs/browser/tests/test_bugtracker_component.py b/lib/lp/bugs/browser/tests/test_bugtracker_component.py
76index a80c254..5d24556 100644
77--- a/lib/lp/bugs/browser/tests/test_bugtracker_component.py
78+++ b/lib/lp/bugs/browser/tests/test_bugtracker_component.py
79@@ -1,4 +1,4 @@
80-# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
81+# Copyright 2010-2020 Canonical Ltd. This software is licensed under the
82 # GNU Affero General Public License version (see the file LICENSE).
83
84 """Unit tests for linking bug tracker components to source packages."""
85@@ -36,7 +36,7 @@ class BugTrackerEditComponentViewTextCase(TestCaseWithFactory):
86 else:
87 name = sourcepackage.name
88 return {
89- 'field.sourcepackagename': name,
90+ 'field.source_package_name': name,
91 'field.actions.save': 'Save',
92 }
93
94@@ -57,7 +57,7 @@ class BugTrackerEditComponentViewTextCase(TestCaseWithFactory):
95 label = 'Link a distribution source package to Example component'
96 self.assertEqual(label, view.label)
97 self.assertEqual('Link component', view.page_title)
98- self.assertEqual(['sourcepackagename'], view.field_names)
99+ self.assertEqual(['source_package_name'], view.field_names)
100 url = canonical_url(component.component_group.bug_tracker)
101 self.assertEqual(url, view.next_url)
102 self.assertEqual(url, view.cancel_url)
103diff --git a/lib/lp/bugs/interfaces/bugtracker.py b/lib/lp/bugs/interfaces/bugtracker.py
104index e2414e9..b0e06fa 100644
105--- a/lib/lp/bugs/interfaces/bugtracker.py
106+++ b/lib/lp/bugs/interfaces/bugtracker.py
107@@ -1,4 +1,4 @@
108-# Copyright 2009-2019 Canonical Ltd. This software is licensed under the
109+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
110 # GNU Affero General Public License version 3 (see the file LICENSE).
111
112 """Bug tracker interfaces."""
113@@ -576,7 +576,7 @@ class IBugTrackerComponent(Interface):
114 title=_('Name'),
115 description=_("The name of a software component "
116 "as shown in Launchpad.")))
117- sourcepackagename = Choice(
118+ source_package_name = Choice(
119 title=_("Package"), required=False, vocabulary='SourcePackageName')
120 distribution = Choice(
121 title=_("Distribution"), required=False, vocabulary='Distribution')
122diff --git a/lib/lp/bugs/model/bugtracker.py b/lib/lp/bugs/model/bugtracker.py
123index 05a2e8f..fe10f33 100644
124--- a/lib/lp/bugs/model/bugtracker.py
125+++ b/lib/lp/bugs/model/bugtracker.py
126@@ -1,4 +1,4 @@
127-# Copyright 2009-2019 Canonical Ltd. This software is licensed under the
128+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
129 # GNU Affero General Public License version 3 (see the file LICENSE).
130
131 __metaclass__ = type
132@@ -731,7 +731,7 @@ class BugTracker(SQLBase):
133 BugTrackerComponent,
134 BugTrackerComponent.distribution == distribution.id,
135 BugTrackerComponent.source_package_name ==
136- dsp.sourcepackagename.id).one()
137+ dsp.sourcepackagename.id).one()
138
139 def getRelatedPillars(self, user=None):
140 """See `IBugTracker`."""