Merge lp:~maxb/bzr-builddeb/mend-indent into lp:bzr-builddeb

Proposed by Max Bowsher
Status: Merged
Approved by: James Westby
Approved revision: 563
Merged at revision: 564
Proposed branch: lp:~maxb/bzr-builddeb/mend-indent
Merge into: lp:bzr-builddeb
Diff against target: 257 lines (+83/-84)
5 files modified
import_dsc.py (+37/-37)
tests/blackbox/test_import_dsc.py (+3/-4)
tests/test_import_dsc.py (+11/-11)
tests/test_merge_upstream.py (+19/-19)
util.py (+13/-13)
To merge this branch: bzr merge lp:~maxb/bzr-builddeb/mend-indent
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+63455@code.launchpad.net

Description of the change

Mend inconsistencies where different indent widths are used at different points
within a single Python source file. I've not attempted to produce consistency
across the project, just ensure each file is internally consistent.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'import_dsc.py'
2--- import_dsc.py 2011-06-03 06:35:14 +0000
3+++ import_dsc.py 2011-06-04 09:06:02 +0000
4@@ -40,7 +40,7 @@
5 from debian import deb822
6 from debian.changelog import Version, Changelog, VersionError
7 except ImportError:
8- # Prior to 0.1.15 the debian module was called debian_bundle
9+ # Prior to 0.1.15 the debian module was called debian_bundle
10 from debian_bundle import deb822
11 from debian_bundle.changelog import Version, Changelog, VersionError
12
13@@ -91,46 +91,46 @@
14
15 class DscCache(object):
16
17- def __init__(self, transport=None):
18- self.cache = {}
19- self.transport_cache = {}
20- self.transport = transport
21-
22- def get_dsc(self, name):
23-
24- if name in self.cache:
25- dsc1 = self.cache[name]
26- else:
27- # Obtain the dsc file, following any redirects as needed.
28- filename, transport = open_transport(name)
29- f1 = open_file_via_transport(filename, transport)
30- try:
31- dsc1 = deb822.Dsc(f1)
32- finally:
33- f1.close()
34- self.cache[name] = dsc1
35- self.transport_cache[name] = transport
36-
37- return dsc1
38-
39- def get_transport(self, name):
40- return self.transport_cache[name]
41+ def __init__(self, transport=None):
42+ self.cache = {}
43+ self.transport_cache = {}
44+ self.transport = transport
45+
46+ def get_dsc(self, name):
47+
48+ if name in self.cache:
49+ dsc1 = self.cache[name]
50+ else:
51+ # Obtain the dsc file, following any redirects as needed.
52+ filename, transport = open_transport(name)
53+ f1 = open_file_via_transport(filename, transport)
54+ try:
55+ dsc1 = deb822.Dsc(f1)
56+ finally:
57+ f1.close()
58+ self.cache[name] = dsc1
59+ self.transport_cache[name] = transport
60+
61+ return dsc1
62+
63+ def get_transport(self, name):
64+ return self.transport_cache[name]
65
66 class DscComp(object):
67
68- def __init__(self, cache):
69- self.cache = cache
70+ def __init__(self, cache):
71+ self.cache = cache
72
73- def cmp(self, dscname1, dscname2):
74- dsc1 = self.cache.get_dsc(dscname1)
75- dsc2 = self.cache.get_dsc(dscname2)
76- v1 = Version(dsc1['Version'])
77- v2 = Version(dsc2['Version'])
78- if v1 == v2:
79- return 0
80- if v1 > v2:
81- return 1
82- return -1
83+ def cmp(self, dscname1, dscname2):
84+ dsc1 = self.cache.get_dsc(dscname1)
85+ dsc2 = self.cache.get_dsc(dscname2)
86+ v1 = Version(dsc1['Version'])
87+ v2 = Version(dsc2['Version'])
88+ if v1 == v2:
89+ return 0
90+ if v1 > v2:
91+ return 1
92+ return -1
93
94
95
96
97=== modified file 'tests/blackbox/test_import_dsc.py'
98--- tests/blackbox/test_import_dsc.py 2011-05-04 15:06:45 +0000
99+++ tests/blackbox/test_import_dsc.py 2011-06-04 09:06:02 +0000
100@@ -32,11 +32,11 @@
101 class TestBaseImportDsc(BuilddebTestCase):
102
103 def _upstream_dir(self, package_name, upstream_version):
104- return package_name + '-' + upstream_version
105+ return package_name + '-' + upstream_version
106 upstream_dir = property(lambda self:self._upstream_dir(self.package_name,
107 self.upstream_version))
108 def _upstream_tarball_name(self, package_name, upstream_version):
109- return package_name + '_' + upstream_version + '.orig.tar.gz'
110+ return package_name + '_' + upstream_version + '.orig.tar.gz'
111 upstream_tarball_name = property(lambda self:
112 self._upstream_tarball_name(self.package_name, self.upstream_version))
113 dsc_name = property(lambda self:
114@@ -119,5 +119,4 @@
115 'package.'], 'import-dsc')
116
117
118-# vim: ts=4 sts=4 sw=4
119-
120+# vim: ts=2 sts=2 sw=2
121
122=== modified file 'tests/test_import_dsc.py'
123--- tests/test_import_dsc.py 2011-01-29 00:13:30 +0000
124+++ tests/test_import_dsc.py 2011-06-04 09:06:02 +0000
125@@ -32,8 +32,8 @@
126 from debian_bundle import deb822
127
128 from bzrlib import (
129- tests,
130- )
131+ tests,
132+ )
133
134 from bzrlib.plugins.builddeb.import_dsc import (
135 DistributionBranch,
136@@ -51,22 +51,22 @@
137
138 class _PristineTarFeature(tests.Feature):
139
140- def feature_name(self):
141- return '/usr/bin/pristine-tar'
142+ def feature_name(self):
143+ return '/usr/bin/pristine-tar'
144
145- def _probe(self):
146- return os.path.exists("/usr/bin/pristine-tar")
147+ def _probe(self):
148+ return os.path.exists("/usr/bin/pristine-tar")
149
150
151 PristineTarFeature = _PristineTarFeature()
152
153
154 def write_to_file(filename, contents):
155- f = open(filename, 'wb')
156- try:
157- f.write(contents)
158- finally:
159- f.close()
160+ f = open(filename, 'wb')
161+ try:
162+ f.write(contents)
163+ finally:
164+ f.close()
165
166
167 class DistributionBranchTests(BuilddebTestCase):
168
169=== modified file 'tests/test_merge_upstream.py'
170--- tests/test_merge_upstream.py 2011-02-03 22:45:27 +0000
171+++ tests/test_merge_upstream.py 2011-06-04 09:06:02 +0000
172@@ -34,25 +34,25 @@
173
174 class TestPackageVersion(TestCase):
175
176- def test_simple_debian(self):
177- self.assertEquals(Version("1.2-1"),
178- package_version("1.2", "debian"))
179-
180- def test_simple_ubuntu(self):
181- self.assertEquals(Version("1.2-0ubuntu1"),
182- package_version("1.2", "ubuntu"))
183-
184- def test_debian_with_dash(self):
185- self.assertEquals(Version("1.2-0ubuntu1-1"),
186- package_version("1.2-0ubuntu1", "debian"))
187-
188- def test_ubuntu_with_dash(self):
189- self.assertEquals(Version("1.2-1-0ubuntu1"),
190- package_version("1.2-1", "ubuntu"))
191-
192- def test_ubuntu_with_epoch(self):
193- self.assertEquals(Version("3:1.2-1-0ubuntu1"),
194- package_version("1.2-1", "ubuntu", "3"))
195+ def test_simple_debian(self):
196+ self.assertEquals(Version("1.2-1"),
197+ package_version("1.2", "debian"))
198+
199+ def test_simple_ubuntu(self):
200+ self.assertEquals(Version("1.2-0ubuntu1"),
201+ package_version("1.2", "ubuntu"))
202+
203+ def test_debian_with_dash(self):
204+ self.assertEquals(Version("1.2-0ubuntu1-1"),
205+ package_version("1.2-0ubuntu1", "debian"))
206+
207+ def test_ubuntu_with_dash(self):
208+ self.assertEquals(Version("1.2-1-0ubuntu1"),
209+ package_version("1.2-1", "ubuntu"))
210+
211+ def test_ubuntu_with_epoch(self):
212+ self.assertEquals(Version("3:1.2-1-0ubuntu1"),
213+ package_version("1.2-1", "ubuntu", "3"))
214
215
216 class UpstreamMergeChangelogLineTests(TestCase):
217
218=== modified file 'util.py'
219--- util.py 2011-04-08 18:47:10 +0000
220+++ util.py 2011-06-04 09:06:02 +0000
221@@ -345,23 +345,23 @@
222
223
224 def open_transport(path):
225- """Obtain an appropriate transport instance for the given path."""
226- base_dir, path = urlutils.split(path)
227- transport = get_transport(base_dir)
228- return (path, transport)
229+ """Obtain an appropriate transport instance for the given path."""
230+ base_dir, path = urlutils.split(path)
231+ transport = get_transport(base_dir)
232+ return (path, transport)
233
234
235 def open_file_via_transport(filename, transport):
236- """Open a file using the transport, follow redirects as necessary."""
237- def open_file(transport):
238- return transport.get(filename)
239- def follow_redirection(transport, e, redirection_notice):
240- mutter(redirection_notice)
241- _filename, redirected_transport = open_transport(e.target)
242- return redirected_transport
243+ """Open a file using the transport, follow redirects as necessary."""
244+ def open_file(transport):
245+ return transport.get(filename)
246+ def follow_redirection(transport, e, redirection_notice):
247+ mutter(redirection_notice)
248+ _filename, redirected_transport = open_transport(e.target)
249+ return redirected_transport
250
251- result = do_catching_redirections(open_file, transport, follow_redirection)
252- return result
253+ result = do_catching_redirections(open_file, transport, follow_redirection)
254+ return result
255
256
257 def _dget(cls, dsc_location, target_dir):

Subscribers

People subscribed via source and target branches