Merge lp:~spiv/bzr/pyflakes-nits into lp:~bzr/bzr/trunk-old
- pyflakes-nits
- Merge into trunk-old
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~spiv/bzr/pyflakes-nits |
Merge into: | lp:~bzr/bzr/trunk-old |
Diff against target: | 663 lines |
To merge this branch: | bzr merge lp:~spiv/bzr/pyflakes-nits |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jelmer Vernooij (community) | Approve | ||
Review via email: mp+8119@code.launchpad.net |
Commit message
Description of the change
Andrew Bennetts (spiv) wrote : | # |
Vincent Ladeuil (vila) wrote : | # |
Review: approve
> Andrew Bennetts has proposed merging
> lp:~spiv/bzr/pyflakes-nits into lp:bzr.
> Most of the changes are just removing unused and redundant
> imports, which should have no effect except removing
> clutter,
That's a good effect :)
<snip/>
> If we want to know what code isn't tested then --coverage
> is a better tool than keeping it broken just so that
> pyflakes can remind us!
Agreed (sadly tracking --coverage for bzr.dev is low on my TODO
list :-/)
> === modified file 'bzrlib/branch.py'
> --- bzrlib/branch.py 2009-06-19 00:33:36 +0000
> +++ bzrlib/branch.py 2009-07-01 10:30:41 +0000
> @@ -35,7 +35,6 @@
> symbol_versioning,
> transport,
> tsort,
> - ui,
> urlutils,
> )
> from bzrlib.config import BranchConfig, TransportConfig
> @@ -2909,7 +2908,7 @@
> @staticmethod
> def _get_branch_
> """Return a tuple with the Branch formats to use when testing."""
> - raise NotImplementedE
> + raise NotImplementedE
Hmpf, too bad the diff doesn't show:
@staticmethod
def _get_branch_
"""Return a tuple with the Branch formats to use when testing."""
raise NotImplementedE
It would have saved me a trip to the source.
> def pull(self, overwrite=False, stop_revision=None,
> possible_
> @@ -3070,7 +3069,6 @@
> _override_
> finally:
> self.source.
> - return result
I was so sure I submitted that one :-(
<snip/>
Thanks a lot for that cleanup.
I usually submit such kind of patch without review (running full
test suite before, during just to catch the typos and after to
be sure).
I was wondering lately if that was still ok ?
Vincent
Jelmer Vernooij (jelmer) wrote : | # |
Would it perhaps be useful to have #TODO comments saying "this needs tests" where relevant?
Preview Diff
1 | === modified file 'bzrlib/branch.py' |
2 | --- bzrlib/branch.py 2009-06-19 00:33:36 +0000 |
3 | +++ bzrlib/branch.py 2009-07-02 11:35:17 +0000 |
4 | @@ -35,7 +35,6 @@ |
5 | symbol_versioning, |
6 | transport, |
7 | tsort, |
8 | - ui, |
9 | urlutils, |
10 | ) |
11 | from bzrlib.config import BranchConfig, TransportConfig |
12 | @@ -2909,7 +2908,7 @@ |
13 | @staticmethod |
14 | def _get_branch_formats_to_test(): |
15 | """Return a tuple with the Branch formats to use when testing.""" |
16 | - raise NotImplementedError(self._get_branch_formats_to_test) |
17 | + raise NotImplementedError(InterBranch._get_branch_formats_to_test) |
18 | |
19 | def pull(self, overwrite=False, stop_revision=None, |
20 | possible_transports=None, local=False): |
21 | @@ -3070,7 +3069,6 @@ |
22 | _override_hook_source_branch=_override_hook_source_branch) |
23 | finally: |
24 | self.source.unlock() |
25 | - return result |
26 | |
27 | def _push_with_bound_branches(self, overwrite, stop_revision, |
28 | _override_hook_source_branch=None): |
29 | |
30 | === modified file 'bzrlib/btree_index.py' |
31 | --- bzrlib/btree_index.py 2009-06-22 12:52:39 +0000 |
32 | +++ bzrlib/btree_index.py 2009-07-02 11:35:17 +0000 |
33 | @@ -17,12 +17,8 @@ |
34 | |
35 | """B+Tree indices""" |
36 | |
37 | -import array |
38 | -import bisect |
39 | from bisect import bisect_right |
40 | -from copy import deepcopy |
41 | import math |
42 | -import struct |
43 | import tempfile |
44 | import zlib |
45 | |
46 | |
47 | === modified file 'bzrlib/builtins.py' |
48 | --- bzrlib/builtins.py 2009-07-01 19:06:14 +0000 |
49 | +++ bzrlib/builtins.py 2009-07-02 11:35:18 +0000 |
50 | @@ -45,7 +45,6 @@ |
51 | revision as _mod_revision, |
52 | symbol_versioning, |
53 | transport, |
54 | - tree as _mod_tree, |
55 | ui, |
56 | urlutils, |
57 | views, |
58 | |
59 | === modified file 'bzrlib/bzrdir.py' |
60 | --- bzrlib/bzrdir.py 2009-06-22 15:13:45 +0000 |
61 | +++ bzrlib/bzrdir.py 2009-07-02 11:35:18 +0000 |
62 | @@ -70,7 +70,6 @@ |
63 | do_catching_redirections, |
64 | get_transport, |
65 | local, |
66 | - remote as remote_transport, |
67 | ) |
68 | from bzrlib.weave import Weave |
69 | """) |
70 | |
71 | === modified file 'bzrlib/chk_map.py' |
72 | --- bzrlib/chk_map.py 2009-06-26 09:24:34 +0000 |
73 | +++ bzrlib/chk_map.py 2009-07-02 11:35:18 +0000 |
74 | @@ -38,14 +38,12 @@ |
75 | """ |
76 | |
77 | import heapq |
78 | -import time |
79 | |
80 | from bzrlib import lazy_import |
81 | lazy_import.lazy_import(globals(), """ |
82 | from bzrlib import versionedfile |
83 | """) |
84 | from bzrlib import ( |
85 | - errors, |
86 | lru_cache, |
87 | osutils, |
88 | registry, |
89 | |
90 | === modified file 'bzrlib/chk_serializer.py' |
91 | --- bzrlib/chk_serializer.py 2009-06-15 19:04:38 +0000 |
92 | +++ bzrlib/chk_serializer.py 2009-07-02 11:35:18 +0000 |
93 | @@ -16,15 +16,10 @@ |
94 | |
95 | """Serializer object for CHK based inventory storage.""" |
96 | |
97 | -from cStringIO import ( |
98 | - StringIO, |
99 | - ) |
100 | - |
101 | from bzrlib import ( |
102 | bencode, |
103 | cache_utf8, |
104 | inventory, |
105 | - osutils, |
106 | revision as _mod_revision, |
107 | xml5, |
108 | xml6, |
109 | |
110 | === modified file 'bzrlib/groupcompress.py' |
111 | --- bzrlib/groupcompress.py 2009-06-29 14:51:13 +0000 |
112 | +++ bzrlib/groupcompress.py 2009-07-02 11:35:18 +0000 |
113 | @@ -16,8 +16,6 @@ |
114 | |
115 | """Core compression logic for compressing streams of related files.""" |
116 | |
117 | -from itertools import izip |
118 | -from cStringIO import StringIO |
119 | import time |
120 | import zlib |
121 | try: |
122 | @@ -28,13 +26,11 @@ |
123 | from bzrlib import ( |
124 | annotate, |
125 | debug, |
126 | - diff, |
127 | errors, |
128 | graph as _mod_graph, |
129 | knit, |
130 | osutils, |
131 | pack, |
132 | - patiencediff, |
133 | trace, |
134 | ) |
135 | from bzrlib.graph import Graph |
136 | |
137 | === modified file 'bzrlib/index.py' |
138 | --- bzrlib/index.py 2009-06-10 03:56:49 +0000 |
139 | +++ bzrlib/index.py 2009-07-02 11:35:18 +0000 |
140 | @@ -39,7 +39,6 @@ |
141 | from bzrlib import ( |
142 | debug, |
143 | errors, |
144 | - symbol_versioning, |
145 | ) |
146 | |
147 | _HEADER_READV = (0, 200) |
148 | |
149 | === modified file 'bzrlib/inventory.py' |
150 | --- bzrlib/inventory.py 2009-06-18 18:18:36 +0000 |
151 | +++ bzrlib/inventory.py 2009-07-02 11:35:18 +0000 |
152 | @@ -27,11 +27,10 @@ |
153 | # created, but it's not for now. |
154 | ROOT_ID = "TREE_ROOT" |
155 | |
156 | -from copy import deepcopy |
157 | - |
158 | from bzrlib.lazy_import import lazy_import |
159 | lazy_import(globals(), """ |
160 | import collections |
161 | +import copy |
162 | import os |
163 | import re |
164 | import tarfile |
165 | @@ -43,7 +42,6 @@ |
166 | generate_ids, |
167 | osutils, |
168 | symbol_versioning, |
169 | - workingtree, |
170 | ) |
171 | """) |
172 | |
173 | @@ -1192,7 +1190,7 @@ |
174 | |
175 | def _get_mutable_inventory(self): |
176 | """See CommonInventory._get_mutable_inventory.""" |
177 | - return deepcopy(self) |
178 | + return copy.deepcopy(self) |
179 | |
180 | def __iter__(self): |
181 | """Iterate over all file-ids.""" |
182 | |
183 | === modified file 'bzrlib/progress.py' |
184 | --- bzrlib/progress.py 2009-06-10 03:56:49 +0000 |
185 | +++ bzrlib/progress.py 2009-07-02 11:35:18 +0000 |
186 | @@ -25,20 +25,15 @@ |
187 | import sys |
188 | import time |
189 | import os |
190 | -import warnings |
191 | |
192 | |
193 | from bzrlib import ( |
194 | errors, |
195 | - osutils, |
196 | - trace, |
197 | - ui, |
198 | ) |
199 | from bzrlib.trace import mutter |
200 | from bzrlib.symbol_versioning import ( |
201 | deprecated_function, |
202 | deprecated_in, |
203 | - deprecated_method, |
204 | ) |
205 | |
206 | |
207 | |
208 | === modified file 'bzrlib/repofmt/groupcompress_repo.py' |
209 | --- bzrlib/repofmt/groupcompress_repo.py 2009-06-29 14:51:13 +0000 |
210 | +++ bzrlib/repofmt/groupcompress_repo.py 2009-07-02 11:35:18 +0000 |
211 | @@ -30,7 +30,6 @@ |
212 | osutils, |
213 | pack, |
214 | remote, |
215 | - repository, |
216 | revision as _mod_revision, |
217 | trace, |
218 | ui, |
219 | @@ -39,7 +38,6 @@ |
220 | BTreeGraphIndex, |
221 | BTreeBuilder, |
222 | ) |
223 | -from bzrlib.index import GraphIndex, GraphIndexBuilder |
224 | from bzrlib.groupcompress import ( |
225 | _GCGraphIndex, |
226 | GroupCompressVersionedFiles, |
227 | |
228 | === modified file 'bzrlib/repofmt/pack_repo.py' |
229 | --- bzrlib/repofmt/pack_repo.py 2009-06-26 09:24:34 +0000 |
230 | +++ bzrlib/repofmt/pack_repo.py 2009-07-02 11:35:18 +0000 |
231 | @@ -36,10 +36,7 @@ |
232 | ) |
233 | from bzrlib.index import ( |
234 | CombinedGraphIndex, |
235 | - GraphIndex, |
236 | - GraphIndexBuilder, |
237 | GraphIndexPrefixAdapter, |
238 | - InMemoryGraphIndex, |
239 | ) |
240 | from bzrlib.knit import ( |
241 | KnitPlainFactory, |
242 | @@ -55,7 +52,6 @@ |
243 | lockable_files, |
244 | lockdir, |
245 | revision as _mod_revision, |
246 | - symbol_versioning, |
247 | ) |
248 | |
249 | from bzrlib.decorators import needs_write_lock |
250 | @@ -75,7 +71,6 @@ |
251 | RootCommitBuilder, |
252 | StreamSource, |
253 | ) |
254 | -import bzrlib.revision as _mod_revision |
255 | from bzrlib.trace import ( |
256 | mutter, |
257 | warning, |
258 | |
259 | === modified file 'bzrlib/repository.py' |
260 | --- bzrlib/repository.py 2009-06-26 09:24:34 +0000 |
261 | +++ bzrlib/repository.py 2009-07-02 11:35:18 +0000 |
262 | @@ -57,9 +57,6 @@ |
263 | entry_factory, |
264 | ) |
265 | from bzrlib import registry |
266 | -from bzrlib.symbol_versioning import ( |
267 | - deprecated_method, |
268 | - ) |
269 | from bzrlib.trace import ( |
270 | log_exception_quietly, note, mutter, mutter_callsite, warning) |
271 | |
272 | @@ -788,8 +785,8 @@ |
273 | # references. |
274 | raise errors.UnsupportedOperation(tree.add_reference, |
275 | self.repository) |
276 | - entry.reference_revision = \ |
277 | - tree.get_reference_revision(change[0]) |
278 | + reference_revision = tree.get_reference_revision(change[0]) |
279 | + entry.reference_revision = reference_revision |
280 | if (carry_over_possible and |
281 | parent_entry.reference_revision == reference_revision): |
282 | carried_over = True |
283 | |
284 | === modified file 'bzrlib/tests/__init__.py' |
285 | --- bzrlib/tests/__init__.py 2009-07-01 15:50:51 +0000 |
286 | +++ bzrlib/tests/__init__.py 2009-07-02 11:35:18 +0000 |
287 | @@ -3007,7 +3007,7 @@ |
288 | """ |
289 | concurrency = osutils.local_concurrency() |
290 | result = [] |
291 | - from subunit import TestProtocolClient, ProtocolTestCase |
292 | + from subunit import ProtocolTestCase |
293 | class TestInSubprocess(ProtocolTestCase): |
294 | def __init__(self, process, name): |
295 | ProtocolTestCase.__init__(self, process.stdout) |
296 | |
297 | === modified file 'bzrlib/tree.py' |
298 | --- bzrlib/tree.py 2009-06-10 03:56:49 +0000 |
299 | +++ bzrlib/tree.py 2009-07-02 11:35:18 +0000 |
300 | @@ -19,7 +19,6 @@ |
301 | |
302 | import os |
303 | from collections import deque |
304 | -from cStringIO import StringIO |
305 | |
306 | import bzrlib |
307 | from bzrlib import ( |
308 | @@ -30,17 +29,16 @@ |
309 | osutils, |
310 | revision as _mod_revision, |
311 | rules, |
312 | - symbol_versioning, |
313 | ) |
314 | from bzrlib.decorators import needs_read_lock |
315 | -from bzrlib.errors import BzrError, BzrCheckError, NoSuchId |
316 | +from bzrlib.errors import BzrError, NoSuchId |
317 | from bzrlib import errors |
318 | -from bzrlib.inventory import Inventory, InventoryFile |
319 | +from bzrlib.inventory import InventoryFile |
320 | from bzrlib.inter import InterObject |
321 | from bzrlib.osutils import fingerprint_file |
322 | import bzrlib.revision |
323 | from bzrlib.symbol_versioning import deprecated_function, deprecated_in |
324 | -from bzrlib.trace import mutter, note |
325 | +from bzrlib.trace import note |
326 | |
327 | |
328 | class Tree(object): |
329 | @@ -437,7 +435,7 @@ |
330 | raise NotImplementedError(self.annotate_iter) |
331 | |
332 | def _get_plan_merge_data(self, file_id, other, base): |
333 | - from bzrlib import merge, versionedfile |
334 | + from bzrlib import versionedfile |
335 | vf = versionedfile._PlanMergeVersionedFile(file_id) |
336 | last_revision_a = self._get_file_revision(file_id, vf, 'this:') |
337 | last_revision_b = other._get_file_revision(file_id, vf, 'other:') |
338 | |
339 | === modified file 'bzrlib/workingtree.py' |
340 | --- bzrlib/workingtree.py 2009-06-17 03:41:33 +0000 |
341 | +++ bzrlib/workingtree.py 2009-07-02 11:35:18 +0000 |
342 | @@ -48,8 +48,6 @@ |
343 | import itertools |
344 | import operator |
345 | import stat |
346 | -from time import time |
347 | -import warnings |
348 | import re |
349 | |
350 | import bzrlib |
351 | @@ -57,29 +55,25 @@ |
352 | branch, |
353 | bzrdir, |
354 | conflicts as _mod_conflicts, |
355 | - dirstate, |
356 | errors, |
357 | generate_ids, |
358 | globbing, |
359 | hashcache, |
360 | ignores, |
361 | + inventory, |
362 | merge, |
363 | revision as _mod_revision, |
364 | revisiontree, |
365 | - repository, |
366 | textui, |
367 | trace, |
368 | transform, |
369 | ui, |
370 | - urlutils, |
371 | views, |
372 | xml5, |
373 | - xml6, |
374 | xml7, |
375 | ) |
376 | import bzrlib.branch |
377 | from bzrlib.transport import get_transport |
378 | -import bzrlib.ui |
379 | from bzrlib.workingtree_4 import ( |
380 | WorkingTreeFormat4, |
381 | WorkingTreeFormat5, |
382 | @@ -89,19 +83,16 @@ |
383 | |
384 | from bzrlib import symbol_versioning |
385 | from bzrlib.decorators import needs_read_lock, needs_write_lock |
386 | -from bzrlib.inventory import InventoryEntry, Inventory, ROOT_ID, TreeReference |
387 | from bzrlib.lockable_files import LockableFiles |
388 | from bzrlib.lockdir import LockDir |
389 | import bzrlib.mutabletree |
390 | from bzrlib.mutabletree import needs_tree_write_lock |
391 | from bzrlib import osutils |
392 | from bzrlib.osutils import ( |
393 | - compact_date, |
394 | file_kind, |
395 | isdir, |
396 | normpath, |
397 | pathjoin, |
398 | - rand_chars, |
399 | realpath, |
400 | safe_unicode, |
401 | splitpath, |
402 | @@ -111,13 +102,12 @@ |
403 | from bzrlib.trace import mutter, note |
404 | from bzrlib.transport.local import LocalTransport |
405 | from bzrlib.progress import DummyProgress, ProgressPhase |
406 | -from bzrlib.revision import NULL_REVISION, CURRENT_REVISION |
407 | +from bzrlib.revision import CURRENT_REVISION |
408 | from bzrlib.rio import RioReader, rio_file, Stanza |
409 | -from bzrlib.symbol_versioning import (deprecated_passed, |
410 | - deprecated_method, |
411 | - deprecated_function, |
412 | - DEPRECATED_PARAMETER, |
413 | - ) |
414 | +from bzrlib.symbol_versioning import ( |
415 | + deprecated_passed, |
416 | + DEPRECATED_PARAMETER, |
417 | + ) |
418 | |
419 | |
420 | MERGE_MODIFIED_HEADER_1 = "BZR merge-modified list format 1" |
421 | @@ -889,7 +879,7 @@ |
422 | branch.last_revision(). |
423 | """ |
424 | from bzrlib.merge import Merger, Merge3Merger |
425 | - pb = bzrlib.ui.ui_factory.nested_progress_bar() |
426 | + pb = ui.ui_factory.nested_progress_bar() |
427 | try: |
428 | merger = Merger(self.branch, this_tree=self, pb=pb) |
429 | merger.pp = ProgressPhase("Merge phase", 5, pb) |
430 | @@ -1081,10 +1071,10 @@ |
431 | branch.BranchReferenceFormat().initialize(tree_bzrdir, new_branch) |
432 | else: |
433 | tree_bzrdir = branch_bzrdir |
434 | - wt = tree_bzrdir.create_workingtree(NULL_REVISION) |
435 | + wt = tree_bzrdir.create_workingtree(_mod_revision.NULL_REVISION) |
436 | wt.set_parent_ids(self.get_parent_ids()) |
437 | my_inv = self.inventory |
438 | - child_inv = Inventory(root_id=None) |
439 | + child_inv = inventory.Inventory(root_id=None) |
440 | new_root = my_inv[file_id] |
441 | my_inv.remove_recursive_id(file_id) |
442 | new_root.parent_id = None |
443 | @@ -1416,7 +1406,8 @@ |
444 | inv = self.inventory |
445 | for entry in moved: |
446 | try: |
447 | - self._move_entry(_RenameEntry(entry.to_rel, entry.from_id, |
448 | + self._move_entry(WorkingTree._RenameEntry( |
449 | + entry.to_rel, entry.from_id, |
450 | entry.to_tail, entry.to_parent_id, entry.from_rel, |
451 | entry.from_tail, entry.from_parent_id, |
452 | entry.only_change_inv)) |
453 | @@ -1573,7 +1564,7 @@ |
454 | @needs_write_lock |
455 | def pull(self, source, overwrite=False, stop_revision=None, |
456 | change_reporter=None, possible_transports=None, local=False): |
457 | - top_pb = bzrlib.ui.ui_factory.nested_progress_bar() |
458 | + top_pb = ui.ui_factory.nested_progress_bar() |
459 | source.lock_read() |
460 | try: |
461 | pp = ProgressPhase("Pull phase", 2, top_pb) |
462 | @@ -1587,7 +1578,7 @@ |
463 | if new_revision_info != old_revision_info: |
464 | pp.next_phase() |
465 | repository = self.branch.repository |
466 | - pb = bzrlib.ui.ui_factory.nested_progress_bar() |
467 | + pb = ui.ui_factory.nested_progress_bar() |
468 | basis_tree.lock_read() |
469 | try: |
470 | new_basis_tree = self.branch.basis_tree() |
471 | @@ -2042,7 +2033,7 @@ |
472 | if filenames is None and len(self.get_parent_ids()) > 1: |
473 | parent_trees = [] |
474 | last_revision = self.last_revision() |
475 | - if last_revision != NULL_REVISION: |
476 | + if last_revision != _mod_revision.NULL_REVISION: |
477 | if basis_tree is None: |
478 | basis_tree = self.basis_tree() |
479 | basis_tree.lock_read() |
480 | @@ -2086,7 +2077,6 @@ |
481 | def set_inventory(self, new_inventory_list): |
482 | from bzrlib.inventory import (Inventory, |
483 | InventoryDirectory, |
484 | - InventoryEntry, |
485 | InventoryFile, |
486 | InventoryLink) |
487 | inv = Inventory(self.get_root_id()) |
488 | @@ -2634,7 +2624,7 @@ |
489 | |
490 | def _change_last_revision(self, revision_id): |
491 | """See WorkingTree._change_last_revision.""" |
492 | - if revision_id is None or revision_id == NULL_REVISION: |
493 | + if revision_id is None or revision_id == _mod_revision.NULL_REVISION: |
494 | try: |
495 | self._transport.delete('last-revision') |
496 | except errors.NoSuchFile: |
497 | @@ -2804,7 +2794,7 @@ |
498 | no working tree. (See bug #43064). |
499 | """ |
500 | sio = StringIO() |
501 | - inv = Inventory() |
502 | + inv = inventory.Inventory() |
503 | xml5.serializer_v5.write_inventory(inv, sio, working=True) |
504 | sio.seek(0) |
505 | transport.put_file('inventory', sio, file_mode) |
506 | @@ -2826,7 +2816,7 @@ |
507 | branch.generate_revision_history(revision_id) |
508 | finally: |
509 | branch.unlock() |
510 | - inv = Inventory() |
511 | + inv = inventory.Inventory() |
512 | wt = WorkingTree2(a_bzrdir.root_transport.local_abspath('.'), |
513 | branch, |
514 | inv, |
515 | @@ -2949,7 +2939,7 @@ |
516 | # only set an explicit root id if there is one to set. |
517 | if basis_tree.inventory.root is not None: |
518 | wt.set_root_id(basis_tree.get_root_id()) |
519 | - if revision_id == NULL_REVISION: |
520 | + if revision_id == _mod_revision.NULL_REVISION: |
521 | wt.set_parent_trees([]) |
522 | else: |
523 | wt.set_parent_trees([(revision_id, basis_tree)]) |
524 | @@ -2962,7 +2952,7 @@ |
525 | return wt |
526 | |
527 | def _initial_inventory(self): |
528 | - return Inventory() |
529 | + return inventory.Inventory() |
530 | |
531 | def __init__(self): |
532 | super(WorkingTreeFormat3, self).__init__() |
533 | |
534 | === modified file 'bzrlib/workingtree_4.py' |
535 | --- bzrlib/workingtree_4.py 2009-06-24 22:35:17 +0000 |
536 | +++ bzrlib/workingtree_4.py 2009-07-02 11:35:18 +0000 |
537 | @@ -28,72 +28,43 @@ |
538 | |
539 | from bzrlib.lazy_import import lazy_import |
540 | lazy_import(globals(), """ |
541 | -from bisect import bisect_left |
542 | -import collections |
543 | -from copy import deepcopy |
544 | import errno |
545 | -import itertools |
546 | -import operator |
547 | import stat |
548 | -from time import time |
549 | -import warnings |
550 | |
551 | import bzrlib |
552 | from bzrlib import ( |
553 | bzrdir, |
554 | cache_utf8, |
555 | - conflicts as _mod_conflicts, |
556 | debug, |
557 | - delta, |
558 | dirstate, |
559 | errors, |
560 | generate_ids, |
561 | - globbing, |
562 | - ignores, |
563 | - merge, |
564 | osutils, |
565 | revision as _mod_revision, |
566 | revisiontree, |
567 | - textui, |
568 | trace, |
569 | transform, |
570 | - urlutils, |
571 | views, |
572 | - xml5, |
573 | - xml6, |
574 | ) |
575 | import bzrlib.branch |
576 | -from bzrlib.transport import get_transport |
577 | import bzrlib.ui |
578 | """) |
579 | |
580 | -from bzrlib import symbol_versioning |
581 | from bzrlib.decorators import needs_read_lock, needs_write_lock |
582 | from bzrlib.filters import filtered_input_file, internal_size_sha_file_byname |
583 | -from bzrlib.inventory import InventoryEntry, Inventory, ROOT_ID, entry_factory |
584 | +from bzrlib.inventory import Inventory, ROOT_ID, entry_factory |
585 | import bzrlib.mutabletree |
586 | from bzrlib.mutabletree import needs_tree_write_lock |
587 | from bzrlib.osutils import ( |
588 | file_kind, |
589 | isdir, |
590 | - normpath, |
591 | pathjoin, |
592 | - rand_chars, |
593 | realpath, |
594 | safe_unicode, |
595 | - splitpath, |
596 | ) |
597 | -from bzrlib.trace import mutter, note |
598 | +from bzrlib.trace import mutter |
599 | from bzrlib.transport.local import LocalTransport |
600 | from bzrlib.tree import InterTree |
601 | -from bzrlib.progress import DummyProgress, ProgressPhase |
602 | -from bzrlib.revision import NULL_REVISION, CURRENT_REVISION |
603 | -from bzrlib.rio import RioReader, rio_file, Stanza |
604 | -from bzrlib.symbol_versioning import (deprecated_passed, |
605 | - deprecated_method, |
606 | - deprecated_function, |
607 | - DEPRECATED_PARAMETER, |
608 | - ) |
609 | from bzrlib.tree import Tree |
610 | from bzrlib.workingtree import WorkingTree, WorkingTree3, WorkingTreeFormat3 |
611 | |
612 | @@ -1051,7 +1022,7 @@ |
613 | def set_last_revision(self, new_revision): |
614 | """Change the last revision in the working tree.""" |
615 | parents = self.get_parent_ids() |
616 | - if new_revision in (NULL_REVISION, None): |
617 | + if new_revision in (_mod_revision.NULL_REVISION, None): |
618 | if len(parents) >= 2: |
619 | raise AssertionError( |
620 | "setting the last parent to none with a pending merge is " |
621 | @@ -1403,7 +1374,7 @@ |
622 | wt.lock_tree_write() |
623 | try: |
624 | self._init_custom_control_files(wt) |
625 | - if revision_id in (None, NULL_REVISION): |
626 | + if revision_id in (None, _mod_revision.NULL_REVISION): |
627 | if branch.repository.supports_rich_root(): |
628 | wt._set_root_id(generate_ids.gen_root_id()) |
629 | else: |
630 | @@ -1420,7 +1391,7 @@ |
631 | pass |
632 | if basis is None: |
633 | basis = branch.repository.revision_tree(revision_id) |
634 | - if revision_id == NULL_REVISION: |
635 | + if revision_id == _mod_revision.NULL_REVISION: |
636 | parents_list = [] |
637 | else: |
638 | parents_list = [(revision_id, basis)] |
639 | @@ -2016,13 +1987,13 @@ |
640 | require_versioned, want_unversioned=want_unversioned) |
641 | parent_ids = self.target.get_parent_ids() |
642 | if not (self.source._revision_id in parent_ids |
643 | - or self.source._revision_id == NULL_REVISION): |
644 | + or self.source._revision_id == _mod_revision.NULL_REVISION): |
645 | raise AssertionError( |
646 | "revision {%s} is not stored in {%s}, but %s " |
647 | "can only be used for trees stored in the dirstate" |
648 | % (self.source._revision_id, self.target, self.iter_changes)) |
649 | target_index = 0 |
650 | - if self.source._revision_id == NULL_REVISION: |
651 | + if self.source._revision_id == _mod_revision.NULL_REVISION: |
652 | source_index = None |
653 | indices = (target_index,) |
654 | else: |
655 | @@ -2090,7 +2061,7 @@ |
656 | (revisiontree.RevisionTree, DirStateRevisionTree)): |
657 | return False |
658 | # the source revid must be in the target dirstate |
659 | - if not (source._revision_id == NULL_REVISION or |
660 | + if not (source._revision_id == _mod_revision.NULL_REVISION or |
661 | source._revision_id in target.get_parent_ids()): |
662 | # TODO: what about ghosts? it may well need to |
663 | # check for them explicitly. |
This patch is almost mechanical. I'm mainly submitting it because I like to
use pyflakes as a sanity check for changes I've made, but existing noise
makes it less convenient than it should be.
Most of the changes are just removing unused and redundant imports, which
should have no effect except removing clutter, and if we're really lucky
it'll make a negligible improvement in start up time too.
Some of these changes are trivially fixing actual bugs (code using variables
that were never defined). Clearly these code paths are untested, or
possibly even completely unused. It would be good to add tests, but in the
meantime cutting down on obvious bugs for minimal effort seems like a good
tradeoff. If we want to know what code isn't tested then --coverage is a
better tool than keeping it broken just so that pyflakes can remind us!
I haven't run pyflakes over every file, or even fixed everything I did find.
This is just some low-hanging fruit I picked on a train last night.
-Andrew.