Merge lp:~jelmer/brz-loom/flake8 into lp:brz-loom

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 170
Proposed branch: lp:~jelmer/brz-loom/flake8
Merge into: lp:brz-loom
Diff against target: 2391 lines (+447/-418)
18 files modified
TODO (+1/-1)
__init__.py (+32/-32)
branch.py (+85/-81)
commands.py (+103/-98)
loom_io.py (+14/-12)
loom_state.py (+11/-10)
releaser.conf (+1/-1)
revspec.py (+8/-14)
setup.py (+0/-1)
tests/__init__.py (+5/-6)
tests/blackbox.py (+79/-61)
tests/test_branch.py (+28/-24)
tests/test_loom_io.py (+10/-12)
tests/test_loom_state.py (+7/-9)
tests/test_revspec.py (+11/-11)
tests/test_tree.py (+17/-15)
tree.py (+32/-27)
version.py (+3/-3)
To merge this branch: bzr merge lp:~jelmer/brz-loom/flake8
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+428650@code.launchpad.net

Commit message

Fix flake8 issues.

Description of the change

Fix flake8 issues.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'TODO'
2--- TODO 2010-07-02 06:15:32 +0000
3+++ TODO 2022-08-19 17:04:03 +0000
4@@ -85,7 +85,7 @@
5 - bug: up-thread incorrectly sets pending merge when the thread is already merged.
6 - UI question - show a marker on all 'applied' threads. i.e. a 'empire state besides the threads list'.
7 - revert-loom thread did not reset branch status correctly in the tree.
8-- bug: up-thread with an out of date tree fails with BzrCommandError not bound.
9+- bug: up-thread with an out of date tree fails with CommandError not bound.
10 - bzr loomify && bzr revert-loom should preserve revision history.
11 - nice errors for loom branch commands on non-loom branches.
12 - better offset management for adjust_current_index.
13
14=== modified file '__init__.py'
15--- __init__.py 2019-08-22 19:36:40 +0000
16+++ __init__.py 2022-08-19 17:04:03 +0000
17@@ -1,19 +1,19 @@
18 # Loom, a plugin for bzr to assist in developing focused patches.
19 # Copyright (C) 2006 Canonical Limited.
20-#
21+#
22 # This program is free software; you can redistribute it and/or modify
23 # it under the terms of the GNU General Public License version 2 as published
24 # by the Free Software Foundation.
25-#
26+#
27 # This program is distributed in the hope that it will be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 # GNU General Public License for more details.
31-#
32+#
33 # You should have received a copy of the GNU General Public License
34 # along with this program; if not, write to the Free Software
35 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36-#
37+#
38
39 from __future__ import absolute_import
40
41@@ -37,7 +37,7 @@
42 * show-loom: Shows the threads in the loom. It currently does not show the
43 # of commits in each thread, but it is planned to do that in the future.
44
45- * down-thread: Move the branch down a thread. After doing this commits and
46+ * down-thread: Move the branch down a thread. After doing this commits and
47 merges in this branch will affect the newly selected thread.
48
49 * up-thread: Move the branch up a thread. This will merge in all the changes
50@@ -47,11 +47,11 @@
51 * combine-thread: Combine the current thread with the thread below it. If
52 It is the last thread, this will currently refuse to operate, but in the
53 future will just turn the loom into a normal branch again. Use this command
54- to remove a thread which has been merged into upstream.
55-
56-
57-Loom also adds new revision specifiers 'thread:' and 'below:'. You can use these
58-to diff against threads in the current Loom. For instance, 'bzr diff -r
59+ to remove a thread which has been merged into upstream.
60+
61+
62+Loom also adds new revision specifiers 'thread:' and 'below:'. You can use
63+these to diff against threads in the current Loom. For instance, 'bzr diff -r
64 thread:' will show you the different between the thread below yours, and your
65 thread. See ``bzr help revisionspec`` for the detailed help on these two
66 revision specifiers.
67@@ -69,6 +69,8 @@
68 from breezy import branch as _mod_branch
69 import breezy.builtins
70 import breezy.commands
71+from breezy.hooks import install_lazy_named_hook
72+from breezy.revisionspec import revspec_registry
73
74 from breezy.plugins.loom import (
75 commands,
76@@ -85,21 +87,22 @@
77 'revert_loom',
78 'show_loom',
79 'up_thread',
80- ]:
81- breezy.commands.plugin_cmds.register_lazy('cmd_' + command, [],
82+]:
83+ breezy.commands.plugin_cmds.register_lazy(
84+ 'cmd_' + command, [],
85 'breezy.plugins.loom.commands')
86
87 # XXX: bzr fix needed: for switch, we have to register directly, not
88 # lazily, because register_lazy does not stack in the same way register_command
89 # does.
90 if not hasattr(breezy.builtins, "cmd_switch"):
91- # provide a switch command (allows
92+ # provide a switch command (allows
93 breezy.commands.register_command(getattr(commands, 'cmd_switch'))
94 else:
95 commands.cmd_switch._original_command = breezy.commands.register_command(
96 getattr(commands, 'cmd_switch'), True)
97
98-from breezy.hooks import install_lazy_named_hook
99+
100 def show_loom_summary(params):
101 branch = getattr(params.new_tree, "branch", None)
102 if branch is None:
103@@ -111,22 +114,17 @@
104 return
105 params.to_file.write('Current thread: %s\n' % branch.nick)
106
107-install_lazy_named_hook('breezy.status', 'hooks', 'post_status',
108+
109+install_lazy_named_hook(
110+ 'breezy.status', 'hooks', 'post_status',
111 show_loom_summary, 'loom status')
112
113-try:
114- from breezy.registry import register_lazy
115-except ImportError: # bzr < 2.6
116- from breezy.revisionspec import revspec_registry
117- revspec_registry.register_lazy('thread:', 'breezy.plugins.loom.revspec',
118- 'RevisionSpecThread')
119- revspec_registry.register_lazy('below:', 'breezy.plugins.loom.revspec',
120- 'RevisionSpecBelow')
121-else:
122- register_lazy("breezy.revisionspec", "revspec_registry", 'thread:',
123- 'breezy.plugins.loom.revspec', 'RevisionSpecThread')
124- register_lazy("breezy.revisionspec", "revspec_registry", 'below:',
125- 'breezy.plugins.loom.revspec', 'RevisionSpecBelow')
126+
127+revspec_registry.register_lazy('thread:', 'breezy.plugins.loom.revspec',
128+ 'RevisionSpecThread')
129+revspec_registry.register_lazy('below:', 'breezy.plugins.loom.revspec',
130+ 'RevisionSpecBelow')
131+
132
133 _LOOM_FORMATS = {
134 b"Bazaar-NG Loom branch format 1\n": "BzrBranchLoomFormat1",
135@@ -137,8 +135,8 @@
136
137 def register_formats():
138 for format_string, kls in _LOOM_FORMATS.items():
139- _mod_branch.format_registry.register_lazy(format_string,
140- "breezy.plugins.loom.branch", kls)
141+ _mod_branch.format_registry.register_lazy(
142+ format_string, "breezy.plugins.loom.branch", kls)
143
144
145 def require_loom_branch(branch):
146@@ -151,15 +149,17 @@
147 class NotALoom(breezy.errors.BzrError):
148
149 _fmt = ("The branch %(branch)s is not a loom. "
150- "You can use 'bzr loomify' to make it into a loom.")
151+ "You can use 'bzr loomify' to make it into a loom.")
152
153 def __init__(self, branch):
154 breezy.errors.BzrError.__init__(self)
155 self.branch = branch
156
157-#register loom formats
158+
159+# register loom formats
160 register_formats()
161
162+
163 def test_suite():
164 import breezy.plugins.loom.tests
165 return breezy.plugins.loom.tests.test_suite()
166
167=== modified file 'branch.py'
168--- branch.py 2020-05-30 17:25:46 +0000
169+++ branch.py 2022-08-19 17:04:03 +0000
170@@ -1,26 +1,26 @@
171 # Loom, a plugin for bzr to assist in developing focused patches.
172 # Copyright (C) 2006 - 2008 Canonical Limited.
173-#
174+#
175 # This program is free software; you can redistribute it and/or modify
176 # it under the terms of the GNU General Public License version 2 as published
177 # by the Free Software Foundation.
178-#
179+#
180 # This program is distributed in the hope that it will be useful,
181 # but WITHOUT ANY WARRANTY; without even the implied warranty of
182 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183 # GNU General Public License for more details.
184-#
185+#
186 # You should have received a copy of the GNU General Public License
187 # along with this program; if not, write to the Free Software
188 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
189-#
190+#
191
192 """The Loom Branch format.
193
194 A Loom branch extends the behaviour of various methods to manage and propogate
195-the Loom specific data. In the future it would be nice to have this data
196+the Loom specific data. In the future it would be nice to have this data
197 registered with a normal bzr branch. That said, the branch format should still
198-be specific to loom, to ensure people have the loom plugin when working on a
199+be specific to loom, to ensure people have the loom plugin when working on a
200 loom branch.
201 """
202
203@@ -33,7 +33,6 @@
204 commit as _mod_commit,
205 controldir,
206 errors,
207- symbol_versioning,
208 trace,
209 ui,
210 urlutils,
211@@ -56,12 +55,12 @@
212 )
213
214
215+from breezy.bzr.fullhistory import BzrBranch5, BzrBranchFormat5
216+
217+
218 EMPTY_REVISION = b'empty:'
219
220
221-from breezy.bzr.fullhistory import BzrBranch5, BzrBranchFormat5
222-
223-
224 def create_thread(loom, thread_name):
225 """Create a thread in the branch loom called thread."""
226 require_loom_branch(loom)
227@@ -102,7 +101,6 @@
228 format.take_over(branch)
229
230
231-
232 class LoomThreadError(errors.BzrError):
233 """Base class for Loom-Thread errors."""
234
235@@ -114,7 +112,8 @@
236
237 class UnrecordedRevision(errors.BzrError):
238
239- _fmt = """The revision %(revision_id)s is not recorded in the loom %(branch)s."""
240+ _fmt = """The revision %(revision_id)s is not recorded in the loom \
241+%(branch)s."""
242
243 def __init__(self, branch, revision_id):
244 errors.BzrError.__init__(self)
245@@ -167,7 +166,7 @@
246 self._inventory.add(loom_meta_ie)
247 self._loom_stream = loom_stream
248 self._loom_sha1 = loom_sha1
249-
250+
251 def get_file(self, path, file_id=None):
252 """Get the content of file_id from this tree.
253
254@@ -179,7 +178,7 @@
255 return (self.get_file(path, file_id), None)
256
257 def get_file_sha1(self, path, file_id=None, stat_value=None):
258- """Get the sha1 for a file.
259+ """Get the sha1 for a file.
260
261 This tree only has one file, so it MUST be present!
262 """
263@@ -189,7 +188,7 @@
264
265 def is_executable(self, path, file_id=None):
266 """get the executable status for file_id.
267-
268+
269 Nothing in a LoomMetaTree is executable.
270 """
271 return False
272@@ -218,7 +217,7 @@
273 self.generate_revision_history(breezy.revision.NULL_REVISION)
274 return
275 # TODO, calculate the offset of removed threads.
276- # i.e. if there are ten threads removed, and current_index is 5,
277+ # i.e. if there are ten threads removed, and current_index is 5,
278 # if 4 of the ten removed were 2,3,4,5, then the new index should
279 # be 2.
280 if len(threads) <= current_index:
281@@ -251,10 +250,10 @@
282 # Looms are not currently bindable.
283 raise errors.UpgradeRequired(self.base)
284
285- def clone(self, to_controldir, revision_id=None, repository_policy=None, name=None,
286- tag_selector=None):
287+ def clone(self, to_controldir, revision_id=None, repository_policy=None,
288+ name=None, tag_selector=None):
289 """Clone the branch into to_controldir.
290-
291+
292 This differs from the base clone by cloning the loom, setting the
293 current nick to the top of the loom, not honouring any branch format
294 selection on the target controldir, and ensuring that the format of
295@@ -262,8 +261,9 @@
296 """
297 # If the target is a stackable repository, force-upgrade the
298 # output loom format
299- if (isinstance(to_controldir, bzrdir.BzrDirMeta1) and
300- to_controldir._format.repository_format.supports_external_lookups):
301+ if (isinstance(to_controldir, bzrdir.BzrDirMeta1)
302+ and (to_controldir._format.repository_format.
303+ supports_external_lookups)):
304 format = BzrBranchLoomFormat7()
305 else:
306 format = self._format
307@@ -277,7 +277,7 @@
308
309 def _get_checkout_format(self, lightweight=False):
310 """Checking out a Loom gets a regular branch for now.
311-
312+
313 This is a short term measure to get to an all-tests passing status.
314 """
315 format = self.repository.controldir.checkout_metadir()
316@@ -291,7 +291,7 @@
317 reader = loom_io.LoomStateReader(current_content)
318 state = loom_state.LoomState(reader)
319 return state
320-
321+
322 def get_old_bound_location(self):
323 """Return the URL of the branch we used to be bound to."""
324 # No binding for looms yet.
325@@ -303,10 +303,6 @@
326 :param rev_id: A specific loom revision to retrieve.
327 :return: a list of threads. e.g. [('threadname', 'last_revision')]
328 """
329- if rev_id is None:
330- symbol_versioning.warn('NULL_REVISION should be used for the null'
331- ' revision instead of None, as of bzr 0.90.',
332- DeprecationWarning, stacklevel=2)
333 if is_null(rev_id):
334 return []
335 content = self._loom_content(rev_id)
336@@ -324,7 +320,8 @@
337 user_location = urlutils.unescape_for_display(
338 thread_transport.base, 'utf-8')
339 try:
340- control_dir = controldir.ControlDir.open(thread_transport.base,
341+ control_dir = controldir.ControlDir.open(
342+ thread_transport.base,
343 possible_transports=[thread_transport])
344 tree, branch = control_dir._get_tree_branch()
345 except errors.NotBranchError:
346@@ -336,8 +333,8 @@
347 thread_transport.base)
348 else:
349 if thread_revision == branch.last_revision():
350- trace.note('Skipping up-to-date branch at %s'
351- % user_location)
352+ trace.note('Skipping up-to-date branch at %s',
353+ user_location)
354 continue
355 else:
356 trace.note('Updating branch at %s' % user_location)
357@@ -413,7 +410,7 @@
358 if not len(threads):
359 # No threads at all - probably a default initialised loom in the
360 # test suite.
361- return self._set_nick(nick)
362+ return self._set_nick(nick)
363 current_index = state.thread_index(self.nick)
364 threads[current_index] = (nick,) + threads[current_index][1:]
365 state.set_threads(threads)
366@@ -436,13 +433,14 @@
367 return must_fetch, should_fetch
368
369 def push(self, target, overwrite=False, stop_revision=None, lossy=False,
370- _override_hook_source_branch=None):
371+ _override_hook_source_branch=None):
372 # Not ideal, but see the issues raised on bazaar@lists.canonical.com
373 # about the push api needing work.
374 with self.lock_read():
375 if not isinstance(target, LoomSupport):
376- return super(LoomSupport, self).push(target, overwrite,
377- stop_revision, lossy=lossy, _override_hook_source_branch=None)
378+ return super(LoomSupport, self).push(
379+ target, overwrite, stop_revision, lossy=lossy,
380+ _override_hook_source_branch=None)
381 if lossy:
382 raise errors.LossyPushToSameVCS(self, target)
383 return _Pusher(self, target).transfer(overwrite, stop_revision,
384@@ -475,16 +473,18 @@
385 except IndexError:
386 basis_revid = breezy.revision.NULL_REVISION
387 for unused in builder.record_iter_changes(
388- loom_tree, basis_revid,
389- loom_tree.iter_changes(self.repository.revision_tree(basis_revid))):
390+ loom_tree, basis_revid,
391+ loom_tree.iter_changes(
392+ self.repository.revision_tree(basis_revid))):
393 pass
394 builder.finish_inventory()
395 rev_id = builder.commit(commit_message)
396 state.set_parents([rev_id])
397- state.set_threads((thread + ([thread[1]],) for thread in new_threads))
398+ state.set_threads(
399+ (thread + ([thread[1]],) for thread in new_threads))
400 self._set_last_loom(state)
401 return rev_id
402-
403+
404 def record_thread(self, thread_name, revision_id):
405 """Record an updated version of an existing thread.
406
407@@ -534,19 +534,19 @@
408 # reset the parents list to just the basis.
409 if basis_rev_id is not None:
410 state.set_parents([basis_rev_id])
411- self._adjust_nick_after_changing_threads(state.get_threads(), position)
412+ self._adjust_nick_after_changing_threads(
413+ state.get_threads(), position)
414 self._set_last_loom(state)
415
416 def revert_thread(self, thread):
417 """Revert a single thread.
418-
419+
420 :param thread: the thread to restore to its state in
421- the basis. If it was not present in the basis it
422+ the basis. If it was not present in the basis it
423 will be removed from the current loom.
424 """
425 with self.lock_write():
426 state = self.get_loom_state()
427- parents = state.get_parents()
428 threads = state.get_threads()
429 position = state.thread_index(thread)
430 basis_threads = self.get_threads(state.get_basis_revision_id())
431@@ -574,8 +574,8 @@
432 If at the end of the lock, the current revision in the branch is not
433 recorded correctly in the loom, an automatic record is attempted.
434 """
435- if (self.control_files._lock_count==1 and
436- self.control_files._lock_mode=='w'):
437+ if (self.control_files._lock_count == 1
438+ and self.control_files._lock_mode == 'w'):
439 # about to release the lock
440 state = self.get_loom_state()
441 threads = state.get_threads()
442@@ -645,10 +645,10 @@
443 if new_rev == EMPTY_REVISION:
444 new_rev = breezy.revision.NULL_REVISION
445 fetch_spec = self.build_fetch_spec(stop_revision)
446- self.target.repository.fetch(self.source.repository,
447- fetch_spec=fetch_spec)
448- self.target.generate_revision_history(new_rev, self.target.last_revision(),
449- self.source)
450+ self.target.repository.fetch(
451+ self.source.repository, fetch_spec=fetch_spec)
452+ self.target.generate_revision_history(
453+ new_rev, self.target.last_revision(), self.source)
454 tag_ret = self.source.tags.merge_to(self.target.tags)
455 if isinstance(tag_ret, tuple):
456 result.tag_updates, result.tag_conflicts = tag_ret
457@@ -668,7 +668,8 @@
458 return factory.make_fetch_spec()
459
460 def transfer(self, overwrite, stop_revision, run_hooks=True,
461- possible_transports=None, _override_hook_target=None, local=False):
462+ possible_transports=None, _override_hook_target=None,
463+ local=False):
464 """Implementation of push and pull"""
465 if local:
466 raise errors.LocalRequiresBoundBranch()
467@@ -690,22 +691,20 @@
468 # is the loom compatible?
469 if len(my_state.get_parents()) > 0:
470 graph = self.source.repository.get_graph()
471- if not graph.is_ancestor(my_state.get_parents()[0],
472- source_loom_rev):
473+ if not graph.is_ancestor(
474+ my_state.get_parents()[0], source_loom_rev):
475 raise errors.DivergedBranches(
476 self.target, self.source)
477 # fetch the loom content
478- self.target.repository.fetch(self.source.repository,
479- revision_id=source_loom_rev)
480+ self.target.repository.fetch(
481+ self.source.repository, revision_id=source_loom_rev)
482 # get the threads for the new basis
483 threads = self.target.get_threads(
484 source_state.get_basis_revision_id())
485- # stopping at from our repository.
486- revisions = [rev for name,rev in threads]
487 # fetch content for all threads and tags.
488 fetch_spec = self.build_fetch_spec(stop_revision)
489- self.target.repository.fetch(self.source.repository,
490- fetch_spec=fetch_spec)
491+ self.target.repository.fetch(
492+ self.source.repository, fetch_spec=fetch_spec)
493 # set our work threads to match (this is where we lose data if
494 # there are local mods)
495 my_state.set_threads(
496@@ -747,7 +746,7 @@
497
498 class LoomBranch(LoomSupport, BzrBranch5):
499 """The Loom branch.
500-
501+
502 A mixin is used as the easiest migration path to support branch6. A
503 delegated object may well be cleaner.
504 """
505@@ -778,7 +777,8 @@
506 def initialize(self, a_controldir, name=None, repository=None,
507 append_revisions_only=None):
508 """Create a branch of this format in a_controldir."""
509- super(LoomFormatMixin, self).initialize(a_controldir, name=name,
510+ super(LoomFormatMixin, self).initialize(
511+ a_controldir, name=name,
512 repository=repository,
513 append_revisions_only=append_revisions_only)
514
515@@ -800,8 +800,9 @@
516 control_files.unlock()
517 return self.open(a_controldir, _found=True, name=name)
518
519- def open(self, a_controldir, name=None, _found=False, ignore_fallbacks=False,
520- found_repository=None, possible_transports=None):
521+ def open(self, a_controldir, name=None, _found=False,
522+ ignore_fallbacks=False,
523+ found_repository=None, possible_transports=None):
524 """Return the branch object for a_controldir
525
526 _found is a private parameter, do not use it. It is used to indicate
527@@ -812,19 +813,21 @@
528 if name is None:
529 name = a_controldir._get_selected_branch()
530 if not _found:
531- format = breezy.branch.BranchFormat.find_format(a_controldir, name=name)
532+ format = breezy.branch.BranchFormat.find_format(
533+ a_controldir, name=name)
534 assert format.__class__ == self.__class__
535 transport = a_controldir.get_branch_transport(None, name=name)
536 control_files = breezy.lockable_files.LockableFiles(
537 transport, 'lock', breezy.lockdir.LockDir)
538 if found_repository is None:
539 found_repository = a_controldir.find_repository()
540- return self._branch_class()(_format=self,
541- _control_files=control_files,
542- a_controldir=a_controldir,
543- _repository=found_repository,
544- ignore_fallbacks=ignore_fallbacks,
545- name=name)
546+ return self._branch_class()(
547+ _format=self,
548+ _control_files=control_files,
549+ a_controldir=a_controldir,
550+ _repository=found_repository,
551+ ignore_fallbacks=ignore_fallbacks,
552+ name=name)
553
554 def take_over(self, branch):
555 """Take an existing breezy branch over into Loom format.
556@@ -844,7 +847,6 @@
557 branch._transport.put_file('last-loom', state_stream)
558
559
560-
561 class BzrBranchLoomFormat1(LoomFormatMixin, BzrBranchFormat5):
562 """Loom's first format.
563
564@@ -870,7 +872,7 @@
565 def get_format_description(self):
566 """See BranchFormat.get_format_description()."""
567 return "Loom branch format 1"
568-
569+
570 def __str__(self):
571 return "Bazaar-NG Loom format 1"
572
573@@ -987,7 +989,8 @@
574 loom_tip = parents[0]
575 else:
576 loom_tip = None
577- threads = self.get_threads(self.source, state.get_basis_revision_id())
578+ threads = self.get_threads(
579+ self.source, state.get_basis_revision_id())
580 if revision_id not in (None, NULL_REVISION):
581 if threads:
582 # revision_id should be in the loom, or its an error
583@@ -1006,13 +1009,13 @@
584 nested = ui.ui_factory.nested_progress_bar()
585 try:
586 if parents:
587- self.target.repository.fetch(self.source.repository,
588- revision_id=parents[0])
589+ self.target.repository.fetch(
590+ self.source.repository, revision_id=parents[0])
591 if threads:
592 for thread, rev_id in reversed(threads):
593 # fetch the loom content for this revision
594- self.target.repository.fetch(self.source.repository,
595- revision_id=rev_id)
596+ self.target.repository.fetch(
597+ self.source.repository, revision_id=rev_id)
598 finally:
599 nested.finished()
600 state = loom_state.LoomState()
601@@ -1048,8 +1051,8 @@
602 self.target.tags, seletor=tag_selector)
603
604 def pull(self, overwrite=False, stop_revision=None,
605- run_hooks=True, possible_transports=None, _override_hook_target=None,
606- local=False, tag_selector=None):
607+ run_hooks=True, possible_transports=None,
608+ _override_hook_target=None, local=False, tag_selector=None):
609 """Perform a pull, reading from self.source and writing to self.target.
610
611 If the source branch is a non-loom branch, the pull is done against the
612@@ -1058,10 +1061,11 @@
613 """
614 with self.lock_write():
615 # Special code only needed when both source and targets are looms:
616- if (self.__class__.branch_is_loom(self.target) and
617- self.__class__.branch_is_loom(self.source)):
618- return _Puller(self.source, self.target).transfer(overwrite, stop_revision,
619- run_hooks, possible_transports, _override_hook_target, local)
620+ if (self.__class__.branch_is_loom(self.target)
621+ and self.__class__.branch_is_loom(self.source)):
622+ return _Puller(self.source, self.target).transfer(
623+ overwrite, stop_revision, run_hooks, possible_transports,
624+ _override_hook_target, local)
625 return super(InterLoomBranch, self).pull(
626 overwrite=overwrite, stop_revision=stop_revision,
627 possible_transports=possible_transports,
628
629=== modified file 'commands.py'
630--- commands.py 2019-08-22 19:36:40 +0000
631+++ commands.py 2022-08-19 17:04:03 +0000
632@@ -1,38 +1,30 @@
633 # Loom, a plugin for bzr to assist in developing focused patches.
634 # Copyright (C) 2006, 2008 Canonical Limited.
635-#
636+#
637 # This program is free software; you can redistribute it and/or modify
638 # it under the terms of the GNU General Public License version 2 as published
639 # by the Free Software Foundation.
640-#
641+#
642 # This program is distributed in the hope that it will be useful,
643 # but WITHOUT ANY WARRANTY; without even the implied warranty of
644 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 # GNU General Public License for more details.
646-#
647+#
648 # You should have received a copy of the GNU General Public License
649 # along with this program; if not, write to the Free Software
650 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
651-#
652+#
653
654 """Loom commands."""
655
656-from __future__ import absolute_import
657-
658 from breezy import controldir, directory_service, workingtree
659 import breezy.commands
660 import breezy.branch
661 from breezy import errors
662-from breezy.lazy_import import lazy_import
663 from breezy.option import Option
664 import breezy.trace
665 import breezy.transport
666
667-lazy_import(globals(), """
668-from breezy.plugins.loom import branch
669-from breezy.plugins.loom.tree import LoomTreeDecorator
670-""")
671-
672
673 class cmd_loomify(breezy.commands.Command):
674 """Add a loom to this branch.
675@@ -51,19 +43,17 @@
676 help='The name to use for the base thread.')]
677
678 def run(self, location='.', base=None):
679+ from breezy.plugins.loom.branch import loomify
680 (target, path) = breezy.branch.Branch.open_containing(location)
681- target.lock_write()
682- try:
683+ with target.lock_write():
684 if base is not None:
685 target.nick = base
686 elif not target.get_config().has_explicit_nickname():
687- raise errors.BzrCommandError(
688+ raise errors.CommandError(
689 'You must specify --base or have a branch nickname set to'
690 ' loomify a branch')
691- branch.loomify(target)
692+ loomify(target)
693 loom = target.controldir.open_branch()
694- finally:
695- target.unlock()
696 # requires a new lock as its a new instance, XXX: teach bzrdir about
697 # format changes ?
698 loom.new_thread(loom.nick)
699@@ -71,10 +61,10 @@
700
701 class cmd_combine_thread(breezy.commands.Command):
702 __doc__ = """Combine the current thread with the thread below it.
703-
704+
705 This will currently refuse to operate on the last thread, but in the future
706 will just turn the loom into a normal branch again.
707-
708+
709 Use combine-thread to remove a thread which has been merged into upstream.
710
711 In precise terms this will:
712@@ -84,51 +74,59 @@
713
714 takes_options = [
715 Option('force', help='Combine even if work in the thread is not '
716- 'integrated up or down the loom.'),
717+ 'integrated up or down the loom.'),
718 ]
719
720 def run(self, force=False):
721+ from breezy.plugins.loom.branch import (
722+ require_loom_branch,
723+ CannotCombineOnLastThread,
724+ )
725+ from breezy.plugins.loom.tree import LoomTreeDecorator
726 (tree, path) = workingtree.WorkingTree.open_containing('.')
727- branch.require_loom_branch(tree.branch)
728- self.add_cleanup(tree.lock_write().unlock)
729- current_thread = tree.branch.nick
730- state = tree.branch.get_loom_state()
731- if not force:
732- # Check for unmerged work.
733- # XXX: Layering issue whom should be caring for the check, not the
734- # command thats for sure.
735- threads = state.get_threads()
736- current_index = state.thread_index(current_thread)
737- rev_below = None
738- rev_current = threads[current_index][1]
739- rev_above = None
740- if current_index:
741- # There is a thread below
742- rev_below = threads[current_index - 1][1]
743- if current_index < len(threads) - 1:
744- rev_above = threads[current_index + 1][1]
745- graph = tree.branch.repository.get_graph()
746- candidates = [rev for rev in
747- (rev_below, rev_current, rev_above) if rev]
748- heads = graph.heads(candidates)
749- # If current is not a head, its trivially merged, or
750- # if current is == rev_below, its also merged, or
751- # if there is only one thread its merged (well its not unmerged).
752- if (rev_current == rev_below or rev_current not in heads or
753- (rev_below is None and rev_above is None)):
754- merged = True
755- else:
756- merged = False
757- if not merged:
758- raise errors.BzrCommandError("Thread '%s' has unmerged work"
759- ". Use --force to combine anyway." % current_thread)
760- new_thread = state.get_new_thread_after_deleting(current_thread)
761- if new_thread is None:
762- raise branch.CannotCombineOnLastThread
763- breezy.trace.note("Combining thread '%s' into '%s'",
764- current_thread, new_thread)
765- LoomTreeDecorator(tree).down_thread(new_thread)
766- tree.branch.remove_thread(current_thread)
767+ require_loom_branch(tree.branch)
768+ with tree.lock_write():
769+ current_thread = tree.branch.nick
770+ state = tree.branch.get_loom_state()
771+ if not force:
772+ # Check for unmerged work.
773+ # XXX: Layering issue whom should be caring for the check, not
774+ # the command thats for sure.
775+ threads = state.get_threads()
776+ current_index = state.thread_index(current_thread)
777+ rev_below = None
778+ rev_current = threads[current_index][1]
779+ rev_above = None
780+ if current_index:
781+ # There is a thread below
782+ rev_below = threads[current_index - 1][1]
783+ if current_index < len(threads) - 1:
784+ rev_above = threads[current_index + 1][1]
785+ graph = tree.branch.repository.get_graph()
786+ candidates = [
787+ rev for rev in (rev_below, rev_current, rev_above) if rev]
788+ heads = graph.heads(candidates)
789+ # If current is not a head, its trivially merged, or
790+ # if current is == rev_below, its also merged, or
791+ # if there is only one thread its merged (well its not
792+ # unmerged).
793+ if (rev_current == rev_below or rev_current not in heads
794+ or (rev_below is None and rev_above is None)):
795+ merged = True
796+ else:
797+ merged = False
798+ if not merged:
799+ raise errors.CommandError(
800+ "Thread '%s' has unmerged work"
801+ ". Use --force to combine anyway." % current_thread)
802+ new_thread = state.get_new_thread_after_deleting(current_thread)
803+ if new_thread is None:
804+ raise CannotCombineOnLastThread()
805+ breezy.trace.note(
806+ "Combining thread '%s' into '%s'",
807+ current_thread, new_thread)
808+ LoomTreeDecorator(tree).down_thread(new_thread)
809+ tree.branch.remove_thread(current_thread)
810
811
812 class cmd_create_thread(breezy.commands.Command):
813@@ -146,8 +144,9 @@
814 takes_args = ['thread']
815
816 def run(self, thread):
817+ from breezy.plugins.loom.branch import create_thread
818 (loom, path) = breezy.branch.Branch.open_containing('.')
819- branch.create_thread(loom, thread)
820+ create_thread(loom, thread)
821
822
823 class cmd_show_loom(breezy.commands.Command):
824@@ -161,10 +160,10 @@
825 takes_args = ['location?']
826
827 def run(self, location='.'):
828+ from breezy.plugins.loom.branch import require_loom_branch
829 (loom, path) = breezy.branch.Branch.open_containing(location)
830- branch.require_loom_branch(loom)
831- loom.lock_read()
832- try:
833+ require_loom_branch(loom)
834+ with loom.lock_read():
835 threads = loom.get_loom_state().get_threads()
836 nick = loom.nick
837 for thread, revid, parents in reversed(threads):
838@@ -173,20 +172,18 @@
839 else:
840 symbol = ' '
841 self.outf.write(symbol + thread + '\n')
842- finally:
843- loom.unlock()
844
845
846 class cmd_switch(breezy.builtins.cmd_switch):
847 """Set the branch of a checkout and update.
848-
849+
850 For looms, this is equivalent to 'down-thread' when to_location is the name
851 of a thread in the loom.
852 For lightweight checkouts, this changes the branch being referenced.
853 For heavyweight checkouts, this checks that there are no local commits
854 versus the current bound branch, then it makes the local branch a mirror
855 of the new location and binds to it.
856-
857+
858 In both cases, the working tree is updated and uncommitted changes
859 are merged. The user can commit or revert these as they desire.
860
861@@ -211,6 +208,12 @@
862
863 def run(self, to_location=None, force=False, create_branch=False,
864 revision=None, directory=None):
865+ from breezy.plugins.loom.branch import (
866+ create_thread,
867+ NoSuchThread,
868+ NotALoom,
869+ )
870+ from breezy.plugins.loom.tree import LoomTreeDecorator
871 # The top of this is cribbed from bzr; because bzr isn't factored out
872 # enough.
873 if directory is None:
874@@ -218,7 +221,7 @@
875 control_dir, path = controldir.ControlDir.open_containing(directory)
876 if to_location is None:
877 if revision is None:
878- raise errors.BzrCommandError(
879+ raise errors.CommandError(
880 'You must supply either a revision or a location')
881 to_location = '.'
882 try:
883@@ -227,7 +230,7 @@
884 from_branch = None
885 if create_branch:
886 if from_branch is None:
887- raise errors.BzrCommandError(
888+ raise errors.CommandError(
889 'cannot create branch without source branch')
890 to_location = directory_service.directories.dereference(
891 to_location)
892@@ -237,10 +240,10 @@
893 tree = LoomTreeDecorator(tree)
894 try:
895 if create_branch:
896- return branch.create_thread(tree.branch, to_location)
897+ return create_thread(tree.branch, to_location)
898 thread_name = self._get_thread_name(tree.branch, to_location)
899 return tree.down_thread(thread_name)
900- except (AttributeError, branch.NoSuchThread, branch.NotALoom):
901+ except (AttributeError, NoSuchThread, NotALoom):
902 # When there is no thread its probably an external branch
903 # that we have been given.
904 raise errors.MustUseDecorated
905@@ -250,7 +253,7 @@
906
907 def run_argv_aliases(self, argv, alias_argv=None):
908 """Parse command line and run.
909-
910+
911 If the command requests it, run the decorated version.
912 """
913 try:
914@@ -262,20 +265,22 @@
915
916
917 class cmd_record(breezy.commands.Command):
918- """Record the current last-revision of this tree into the current thread."""
919+ """Record the current last-revision of this tree into the current thread.
920+ """
921
922 takes_args = ['message']
923
924 def run(self, message):
925+ from breezy.plugins.loom.branch import require_loom_branch
926 (abranch, path) = breezy.branch.Branch.open_containing('.')
927- branch.require_loom_branch(abranch)
928+ require_loom_branch(abranch)
929 abranch.record_loom(message)
930 breezy.trace.note("Loom recorded.")
931
932
933 class cmd_revert_loom(breezy.commands.Command):
934 """Revert part or all of a loom.
935-
936+
937 This will update the current loom to be the same as the basis when --all
938 is supplied. If no parameters or options are supplied then nothing will
939 happen. If a thread is named, then only that thread is reverted to its
940@@ -283,16 +288,17 @@
941 """
942
943 takes_args = ['thread?']
944- takes_options = [Option('all',
945- help='Revert all threads.'),
946+ takes_options = [Option('all', help='Revert all threads.'),
947 ]
948
949 def run(self, thread=None, all=None):
950 if thread is None and all is None:
951 breezy.trace.note('Please see revert-loom -h.')
952 return
953+ from breezy.plugins.loom.branch import require_loom_branch
954+ from breezy.plugins.loom.tree import LoomTreeDecorator
955 (tree, path) = workingtree.WorkingTree.open_containing('.')
956- branch.require_loom_branch(tree.branch)
957+ require_loom_branch(tree.branch)
958 tree = LoomTreeDecorator(tree)
959 if all:
960 tree.revert_loom()
961@@ -317,22 +323,18 @@
962 _see_also = ['switch', 'up-thread']
963
964 def run(self, thread=None):
965+ from breezy.plugins.loom.branch import require_loom_branch
966+ from breezy.plugins.loom.tree import LoomTreeDecorator
967 (wt, path) = workingtree.WorkingTree.open_containing('.')
968- branch.require_loom_branch(wt.branch)
969+ require_loom_branch(wt.branch)
970 tree = LoomTreeDecorator(wt)
971- tree.lock_write()
972- try:
973+ with tree.lock_write():
974 basis = wt.basis_tree()
975- basis.lock_read()
976- try:
977+ with basis.lock_read():
978 for change in wt.iter_changes(basis):
979- raise errors.BzrCommandError(
980+ raise errors.CommandError(
981 'Working tree has uncommitted changes.')
982- finally:
983- basis.unlock()
984 return tree.down_thread(thread)
985- finally:
986- tree.unlock()
987
988
989 class cmd_up_thread(breezy.commands.Command):
990@@ -346,20 +348,23 @@
991
992 takes_args = ['thread?']
993
994- takes_options = ['merge-type', Option('auto',
995- help='Deprecated - now the default.'),
996- Option('manual', help='Perform commit manually.'),
997+ takes_options = ['merge-type', Option(
998+ 'auto',
999+ help='Deprecated - now the default.'),
1000+ Option('manual', help='Perform commit manually.'),
1001 ]
1002
1003 _see_also = ['down-thread', 'switch']
1004
1005 def run(self, merge_type=None, manual=False, thread=None, auto=None):
1006+ from breezy.plugins.loom.branch import require_loom_branch
1007+ from breezy.plugins.loom.tree import LoomTreeDecorator
1008 (tree, path) = workingtree.WorkingTree.open_containing('.')
1009- branch.require_loom_branch(tree.branch)
1010+ require_loom_branch(tree.branch)
1011 tree = LoomTreeDecorator(tree)
1012 if manual:
1013 if thread is not None:
1014- raise errors.BzrCommandError('Specifying a thread does not'
1015+ raise errors.CommandError('Specifying a thread does not'
1016 ' work with --manual.')
1017 return tree.up_thread(merge_type)
1018 else:
1019@@ -385,8 +390,8 @@
1020 if location is None:
1021 location = loom.get_config().get_user_option('export_loom_root')
1022 if location is None:
1023- raise errors.BzrCommandError('No export root known or specified.')
1024- root_transport = breezy.transport.get_transport(location,
1025- possible_transports=[loom.controldir.root_transport])
1026+ raise errors.CommandError('No export root known or specified.')
1027+ root_transport = breezy.transport.get_transport(
1028+ location, possible_transports=[loom.controldir.root_transport])
1029 root_transport.ensure_base()
1030 loom.export_threads(root_transport)
1031
1032=== modified file 'loom_io.py'
1033--- loom_io.py 2019-08-22 19:36:40 +0000
1034+++ loom_io.py 2022-08-19 17:04:03 +0000
1035@@ -1,19 +1,19 @@
1036 # Loom, a plugin for bzr to assist in developing focused patches.
1037 # Copyright (C) 2006 Canonical Limited.
1038-#
1039+#
1040 # This program is free software; you can redistribute it and/or modify
1041 # it under the terms of the GNU General Public License version 2 as published
1042 # by the Free Software Foundation.
1043-#
1044+#
1045 # This program is distributed in the hope that it will be useful,
1046 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1047 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1048 # GNU General Public License for more details.
1049-#
1050+#
1051 # You should have received a copy of the GNU General Public License
1052 # along with this program; if not, write to the Free Software
1053 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1054-#
1055+#
1056
1057
1058 """Routines for reading and writing Looms in streams."""
1059@@ -86,7 +86,7 @@
1060 def __init__(self, stream):
1061 """Initialise a LoomStateReader with a serialised loom-state stream.
1062
1063- :param stream: The stream that contains a loom-state object. This
1064+ :param stream: The stream that contains a loom-state object. This
1065 should allow relative seeking.
1066 """
1067 self._stream = stream
1068@@ -107,12 +107,13 @@
1069 # for the reader that is looked up on this format string.
1070 # either way, its in the future.
1071 assert self._content[0] == _CURRENT_LOOM_FORMAT_STRING, \
1072- "%r != %r" % (self._content[0], _CURRENT_LOOM_FORMAT_STRING)
1073+ "%r != %r" % (self._content[0], _CURRENT_LOOM_FORMAT_STRING)
1074
1075 def read_parents(self):
1076 """Read the parents field from the stream.
1077-
1078- :return: a list of parent revision ids.
1079+
1080+ Returns:
1081+ a list of parent revision ids.
1082 """
1083 self._read()
1084 return self._content[1].split()
1085@@ -120,15 +121,16 @@
1086 def read_thread_details(self):
1087 """Read the details for the threads.
1088
1089- :return: a list of thread details. Each thread detail is a 3-tuple
1090+ Returns:
1091+ a list of thread details. Each thread detail is a 3-tuple
1092 containing the thread name, the current thread revision, and a
1093 list of parent thread revisions, in the same order and length
1094- as the list returned by read_parents. In the parent thread
1095- revision list, None means 'no present in the parent', and
1096+ as the list returned by read_parents. In the parent thread
1097+ revision list, None means 'no present in the parent', and
1098 'null:' means 'present but had no commits'.
1099 """
1100 result = []
1101- parent_count = len(self.read_parents())
1102+ len(self.read_parents())
1103 # skip the format and parent lines, and the trailing \n line.
1104 for line in self._content[2:-1]:
1105 conflict_status, line = line.split(b' ', 1)
1106
1107=== modified file 'loom_state.py'
1108--- loom_state.py 2018-05-20 13:59:05 +0000
1109+++ loom_state.py 2022-08-19 17:04:03 +0000
1110@@ -1,19 +1,19 @@
1111 # Loom, a plugin for bzr to assist in developing focused patches.
1112 # Copyright (C) 2006, 2008 Canonical Limited.
1113-#
1114+#
1115 # This program is free software; you can redistribute it and/or modify
1116 # it under the terms of the GNU General Public License version 2 as published
1117 # by the Free Software Foundation.
1118-#
1119+#
1120 # This program is distributed in the hope that it will be useful,
1121 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1122 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1123 # GNU General Public License for more details.
1124-#
1125+#
1126 # You should have received a copy of the GNU General Public License
1127 # along with this program; if not, write to the Free Software
1128 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1129-#
1130+#
1131
1132
1133 """The current-loom state object."""
1134@@ -25,7 +25,7 @@
1135
1136 class LoomState(object):
1137 """The LoomState represents the content of the current-loom branch file.
1138-
1139+
1140 It is planned to not need access to repository data - it will be driven
1141 by the LoomBranch and have data fed into it.
1142 """
1143@@ -53,7 +53,7 @@
1144 return NULL_REVISION
1145 else:
1146 return self._parents[0]
1147-
1148+
1149 def get_parents(self):
1150 """Get the list of loom revisions that are parents to this state."""
1151 return self._parents
1152@@ -63,9 +63,9 @@
1153 return list(self._threads)
1154
1155 def get_threads_dict(self):
1156- """Get the threads as a dict.
1157+ """Get the threads as a dict.
1158
1159- This loses ordering, but is useful for quickly locating the details on
1160+ This loses ordering, but is useful for quickly locating the details on
1161 a given thread.
1162 """
1163 return dict((thread[0], thread[1:]) for thread in self._threads)
1164@@ -100,8 +100,9 @@
1165 def set_threads(self, threads):
1166 """Set the current threads to threads.
1167
1168- :param threads: A list of (name, revid) pairs that make up the threads.
1169- If the list is altered after calling set_threads, there is no
1170+ Args:
1171+ threads: A list of (name, revid) pairs that make up the threads.
1172+ If the list is altered after calling set_threads, there is no
1173 effect on the LoomState.
1174 """
1175 self._threads = list(threads)
1176
1177=== modified file 'releaser.conf'
1178--- releaser.conf 2022-08-19 16:24:40 +0000
1179+++ releaser.conf 2022-08-19 17:04:03 +0000
1180@@ -2,7 +2,7 @@
1181 news_file: "NEWS"
1182 timeout_days: 5
1183 tag_name: "brz-loom-$VERSION"
1184-verify_command: "flake8 && make check"
1185+verify_command: "flake8 && BRZ_PLUGINS_AT=loom@`pwd` brz selftest -s bp.loom"
1186 update_version {
1187 path: "setup.py"
1188 new_line: " version=\"$VERSION\","
1189
1190=== modified file 'revspec.py'
1191--- revspec.py 2018-05-20 13:59:05 +0000
1192+++ revspec.py 2022-08-19 17:04:03 +0000
1193@@ -1,19 +1,19 @@
1194 # Loom, a plugin for bzr to assist in developing focused patches.
1195 # Copyright (C) 2006, 2008 Canonical Limited.
1196-#
1197+#
1198 # This program is free software; you can redistribute it and/or modify
1199 # it under the terms of the GNU General Public License version 2 as published
1200 # by the Free Software Foundation.
1201-#
1202+#
1203 # This program is distributed in the hope that it will be useful,
1204 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1205 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1206 # GNU General Public License for more details.
1207-#
1208+#
1209 # You should have received a copy of the GNU General Public License
1210 # along with this program; if not, write to the Free Software
1211 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1212-#
1213+#
1214
1215 """Loom specific revision-specifiers."""
1216
1217@@ -28,17 +28,14 @@
1218 """A revision spec that needs a loom."""
1219
1220 def _match_on(self, branch, revs):
1221- return RevisionInfo(branch, None, self._as_revision_id(branch))
1222+ return RevisionInfo(branch, None, self._as_revision_id(branch))
1223
1224 def _as_revision_id(self, branch):
1225 require_loom_branch(branch)
1226- branch.lock_read()
1227- try:
1228+ with branch.lock_read():
1229 state = branch.get_loom_state()
1230 threads = state.get_threads()
1231 return self._as_thread_revision_id(branch, state, threads)
1232- finally:
1233- branch.unlock()
1234
1235
1236 class RevisionSpecBelow(LoomRevisionSpec):
1237@@ -46,7 +43,7 @@
1238
1239 help_txt = """Selects the tip of the thread below a thread from a loom.
1240
1241- Selects the tip of the thread below a thread in a loom.
1242+ Selects the tip of the thread below a thread in a loom.
1243
1244 Examples::
1245
1246@@ -77,7 +74,7 @@
1247
1248 help_txt = """Selects the tip of a thread from a loom.
1249
1250- Selects the tip of a thread in a loom.
1251+ Selects the tip of a thread in a loom.
1252
1253 Examples::
1254
1255@@ -100,6 +97,3 @@
1256 if index < 0:
1257 raise NoLowerThread()
1258 return threads[index][1]
1259-
1260-
1261-
1262
1263=== modified file 'setup.py'
1264--- setup.py 2022-08-08 12:17:24 +0000
1265+++ setup.py 2022-08-19 17:04:03 +0000
1266@@ -20,7 +20,6 @@
1267 "Bazaar-NG Loom branch format 6\n": "Loom branch format 6",
1268 }
1269
1270-from version import *
1271
1272 if __name__ == '__main__':
1273 setup(name="brz-loom",
1274
1275=== modified file 'tests/__init__.py'
1276--- tests/__init__.py 2018-05-20 13:59:05 +0000
1277+++ tests/__init__.py 2022-08-19 17:04:03 +0000
1278@@ -1,19 +1,19 @@
1279 # Loom, a plugin for bzr to assist in developing focused patches.
1280 # Copyright (C) 2006 Canonical Limited.
1281-#
1282+#
1283 # This program is free software; you can redistribute it and/or modify
1284 # it under the terms of the GNU General Public License version 2 as published
1285 # by the Free Software Foundation.
1286-#
1287+#
1288 # This program is distributed in the hope that it will be useful,
1289 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1290 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1291 # GNU General Public License for more details.
1292-#
1293+#
1294 # You should have received a copy of the GNU General Public License
1295 # along with this program; if not, write to the Free Software
1296 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1297-#
1298+#
1299
1300
1301 """Tests for the loom plugin."""
1302@@ -21,7 +21,7 @@
1303
1304 import breezy.plugins.loom.branch
1305 from breezy.tests import TestCaseWithTransport
1306-from breezy.tests.TestUtil import TestLoader, TestSuite
1307+from breezy.tests.TestUtil import TestLoader
1308 from breezy.workingtree import WorkingTree
1309
1310
1311@@ -47,4 +47,3 @@
1312 tree = WorkingTree.open(path)
1313 breezy.plugins.loom.branch.loomify(tree.branch)
1314 return tree.controldir.open_workingtree()
1315-
1316
1317=== modified file 'tests/blackbox.py'
1318--- tests/blackbox.py 2019-08-22 19:36:40 +0000
1319+++ tests/blackbox.py 2022-08-19 17:04:03 +0000
1320@@ -1,19 +1,19 @@
1321 # Loom, a plugin for bzr to assist in developing focused patches.
1322 # Copyright (C) 2006, 2008 Canonical Limited.
1323-#
1324+#
1325 # This program is free software; you can redistribute it and/or modify
1326 # it under the terms of the GNU General Public License version 2 as published
1327 # by the Free Software Foundation.
1328-#
1329+#
1330 # This program is distributed in the hope that it will be useful,
1331 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1332 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1333 # GNU General Public License for more details.
1334-#
1335+#
1336 # You should have received a copy of the GNU General Public License
1337 # along with this program; if not, write to the Free Software
1338 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1339-#
1340+#
1341
1342
1343 """UI tests for loom."""
1344@@ -42,8 +42,8 @@
1345
1346 def get_vendor_loom(self, path='.'):
1347 """Make a loom with a vendor thread.
1348-
1349- This returns a loom with a vendor thread, which has the current
1350+
1351+ This returns a loom with a vendor thread, which has the current
1352 commit recorded in it, but nothing in the basis loom - its
1353 empty.
1354 """
1355@@ -54,7 +54,8 @@
1356 return tree.controldir.open_workingtree()
1357
1358 def assert_exception_raised_on_non_loom_branch(self, args):
1359- """Helper to check UserError gets raised when commands are run in a non-loomed branch."""
1360+ """Helper to check UserError gets raised when commands are run in a
1361+ non-loomed branch."""
1362 tree = self.make_branch_and_tree('.')
1363 tree.branch.nick = 'somenick'
1364 out, err = self.run_bzr(args, retcode=3)
1365@@ -65,7 +66,7 @@
1366 class TestLoomify(TestCaseWithLoom):
1367
1368 def test_loomify_new_branch(self):
1369- b = self.make_branch('.')
1370+ self.make_branch('.')
1371 out, err = self.run_bzr(['loomify'], retcode=3)
1372 self.assertEqual('', out)
1373 self.assertEqual(
1374@@ -135,8 +136,10 @@
1375 self.assertEqual('feature-foo', tree.branch.nick)
1376
1377 def test_create_thread_on_non_loomed_branch(self):
1378- """We should raise a user-friendly exception if the branch isn't loomed yet."""
1379- self.assert_exception_raised_on_non_loom_branch(['create-thread', 'some-thread'])
1380+ """We should raise a user-friendly exception if the branch isn't loomed
1381+ yet."""
1382+ self.assert_exception_raised_on_non_loom_branch(
1383+ ['create-thread', 'some-thread'])
1384
1385
1386 class TestShow(TestsWithLooms):
1387@@ -156,7 +159,7 @@
1388
1389 def test_show_loom_with_location(self):
1390 """Should be able to provide an explicit location to show."""
1391- tree = self.get_vendor_loom('subtree')
1392+ self.get_vendor_loom('subtree')
1393 self.assertShowLoom(['vendor'], 'vendor', 'subtree')
1394
1395 def assertShowLoom(self, threads, selected_thread, location=None):
1396@@ -178,7 +181,8 @@
1397 self.assertEqual('', err)
1398
1399 def test_show_loom_on_non_loomed_branch(self):
1400- """We should raise a user-friendly exception if the branch isn't loomed yet."""
1401+ """We should raise a user-friendly exception if the branch isn't loomed
1402+ yet."""
1403 self.assert_exception_raised_on_non_loom_branch(['show-loom'])
1404
1405
1406@@ -188,14 +192,11 @@
1407 super(TestStatus, self).setUp()
1408 # The test suite resets after each run, so manually register
1409 # the loom status hook.
1410- try:
1411- from breezy.hooks import install_lazy_named_hook
1412- except ImportError:
1413- pass
1414- else:
1415- from breezy.plugins.loom import show_loom_summary
1416- install_lazy_named_hook('breezy.status', 'hooks', 'post_status',
1417- show_loom_summary, 'loom status')
1418+ from breezy.hooks import install_lazy_named_hook
1419+ from breezy.plugins.loom import show_loom_summary
1420+ install_lazy_named_hook(
1421+ 'breezy.status', 'hooks', 'post_status',
1422+ show_loom_summary, 'loom status')
1423
1424 def test_status_shows_current_thread(self):
1425 # 'bzr status' shows the current thread.
1426@@ -219,7 +220,7 @@
1427 def test_status_on_non_loom_doesnt_error(self):
1428 # 'bzr status' on a non-loom doesn't error, despite the decoration
1429 # we've added.
1430- tree = self.make_branch_and_tree('.')
1431+ self.make_branch_and_tree('.')
1432 out, err = self.run_bzr(['status'], retcode=0)
1433 self.assertEqual('', out)
1434 self.assertEqual('', err)
1435@@ -295,7 +296,7 @@
1436
1437 def test_record_no_change(self):
1438 """If there are no changes record should error."""
1439- tree = self.get_tree_with_loom()
1440+ self.get_tree_with_loom()
1441 out, err = self.run_bzr(['record', 'Try to commit.'], retcode=3)
1442 self.assertEqual('', out)
1443 self.assertEqual(
1444@@ -311,18 +312,21 @@
1445 self.assertEqual('', out)
1446
1447 def test_record_on_non_loomed_branch(self):
1448- """We should raise a user-friendly exception if the branch isn't loomed yet."""
1449- self.assert_exception_raised_on_non_loom_branch(['record', 'some message'])
1450+ """We should raise a user-friendly exception if the branch isn't loomed
1451+ yet."""
1452+ self.assert_exception_raised_on_non_loom_branch(
1453+ ['record', 'some message'])
1454
1455
1456 class TestDown(TestsWithLooms):
1457
1458 def test_down_thread_from_bottom(self):
1459- tree = self.get_vendor_loom()
1460+ self.get_vendor_loom()
1461 out, err = self.run_bzr(['down-thread'], retcode=3)
1462 self.assertEqual('', out)
1463- self.assertEqual('brz: ERROR: Cannot move down from the lowest thread.\n', err)
1464-
1465+ self.assertEqual(
1466+ 'brz: ERROR: Cannot move down from the lowest thread.\n', err)
1467+
1468 def test_down_thread_same_revision(self):
1469 """moving down when the revision is unchanged should work."""
1470 tree = self.get_vendor_loom()
1471@@ -334,7 +338,7 @@
1472 self.assertEqual("Moved to thread 'vendor'.\n", err)
1473 self.assertEqual('vendor', tree.branch.nick)
1474 self.assertEqual(rev, tree.last_revision())
1475-
1476+
1477 def test_down_thread_removes_changes_between_threads(self):
1478 tree = self.get_vendor_loom()
1479 tree.branch.new_thread('patch')
1480@@ -357,12 +361,14 @@
1481 self.assertFalse(tree.has_filename('afile'))
1482
1483 def test_down_thread_switches_history_ok(self):
1484- """Do a down thread when the lower patch is not in the r-h of the old."""
1485+ """Do a down thread when the lower patch is not in the r-h of the
1486+ old."""
1487 tree = self.get_vendor_loom()
1488 tree.branch.new_thread('patch')
1489 tree.branch._set_nick('vendor')
1490 # do a null change in vendor - a new release.
1491- vendor_release = tree.commit('new vendor release.', allow_pointless=True)
1492+ vendor_release = tree.commit(
1493+ 'new vendor release.', allow_pointless=True)
1494 # pop up, then down
1495 self.run_bzr(['up-thread'])
1496 self.run_bzr(['revert'])
1497@@ -406,7 +412,8 @@
1498 self.assertEqual(None, tree.path2id('patch2'))
1499
1500 def test_down_thread_on_non_loomed_branch(self):
1501- """We should raise a user-friendly exception if the branch isn't loomed yet."""
1502+ """We should raise a user-friendly exception if the branch isn't loomed
1503+ yet."""
1504 self.assert_exception_raised_on_non_loom_branch(['down-thread'])
1505
1506 def test_down_thread_with_changes(self):
1507@@ -424,7 +431,7 @@
1508 class TestUp(TestsWithLooms):
1509
1510 def test_up_thread_from_top(self):
1511- tree = self.get_vendor_loom()
1512+ self.get_vendor_loom()
1513 out, err = self.run_bzr(['up-thread'], retcode=3)
1514 self.assertEqual('', out)
1515 self.assertEqual(
1516@@ -493,7 +500,8 @@
1517 out, err = self.run_bzr(['up-thread'], retcode=1)
1518 self.assertEqual('', out)
1519 self.assertEqual(
1520- 'Conflict adding file afile. Moved existing file to afile.moved.\n'
1521+ 'Conflict adding file afile. '
1522+ 'Moved existing file to afile.moved.\n'
1523 '1 conflicts encountered.\n'
1524 "Moved to thread 'patch'.\n", err)
1525 self.assertEqual('patch', tree.branch.nick)
1526@@ -507,11 +515,12 @@
1527 self.assertEqual([patch_rev, vendor_release], tree.get_parent_ids())
1528
1529 def test_up_thread_on_non_loomed_branch(self):
1530- """We should raise a user-friendly exception if the branch isn't loomed yet."""
1531+ """We should raise a user-friendly exception if the branch isn't loomed
1532+ yet."""
1533 self.assert_exception_raised_on_non_loom_branch(['up-thread'])
1534
1535 def test_up_thread_accepts_merge_type(self):
1536- tree = self.get_vendor_loom()
1537+ self.get_vendor_loom()
1538 self.run_bzr(['create-thread', 'top'])
1539 self.run_bzr(['down-thread'])
1540 self.run_bzr(['up-thread', '--lca'])
1541@@ -526,11 +535,11 @@
1542
1543 def test_up_with_clean_merge_leaving_thread_empty(self):
1544 """This tests what happens when a thread becomes empty.
1545-
1546+
1547 A thread becomes empty when all its changes are included in
1548 a lower thread, and so its diff to the thread below contains
1549 nothing.
1550-
1551+
1552 The user should be warned when this happens.
1553 """
1554 tree = self.get_vendor_loom()
1555@@ -549,10 +558,11 @@
1556 f.write(b'new contents of afile\n')
1557 vendor_release = tree.commit('make the same change to afile')
1558 # check that the trees no longer differ after the up merge,
1559- # and that we are
1560+ # and that we are
1561 out, err = self.run_bzr(['up-thread', '--manual'])
1562 self.assertEqual('', out)
1563- self.assertStartsWith(err,
1564+ self.assertStartsWith(
1565+ err,
1566 "All changes applied successfully.\n"
1567 "Moved to thread 'patch'.\n"
1568 'This thread is now empty, you may wish to run "bzr '
1569@@ -645,14 +655,14 @@
1570
1571 def test_revert_loom(self):
1572 """bzr revert-loom should give help."""
1573- tree = self.get_vendor_loom()
1574+ self.get_vendor_loom()
1575 out, err = self.run_bzr(['revert-loom'])
1576 self.assertEqual('', out)
1577 self.assertEqual('Please see revert-loom -h.\n', err)
1578
1579 def test_revert_loom_missing_thread(self):
1580 """bzr revert-loom missing-thread should give an error."""
1581- tree = self.get_vendor_loom()
1582+ self.get_vendor_loom()
1583 out, err = self.run_bzr(['revert-loom', 'unknown-thread'], retcode=3)
1584 self.assertEqual('', out)
1585 self.assertEqual("brz: ERROR: No such thread 'unknown-thread'.\n", err)
1586@@ -672,11 +682,12 @@
1587 self.assertNotEqual(last_rev, tree.last_revision())
1588 self.assertEqual(NULL_REVISION, tree.last_revision())
1589 self.assertEqual([], tree.branch.get_loom_state().get_threads())
1590-
1591+
1592 def test_revert_thread(self):
1593- """bzr revert-loom threadname should restore the state of that thread."""
1594- # we want a loom with > 1 threads, with a change made to a thread we are
1595- # not in, so we can revert that by name,
1596+ """bzr revert-loom threadname should restore the state of that
1597+ thread."""
1598+ # we want a loom with > 1 threads, with a change made to a thread we
1599+ # are not in, so we can revert that by name,
1600 tree = self.get_vendor_loom()
1601 tree.branch.new_thread('after-vendor')
1602 tree.branch._set_nick('after-vendor')
1603@@ -691,11 +702,14 @@
1604 self.assertEqual('', out)
1605 self.assertEqual("thread 'after-vendor' reverted.\n", err)
1606 self.assertEqual(last_rev, tree.last_revision())
1607- self.assertEqual(old_threads, tree.branch.get_loom_state().get_threads())
1608+ self.assertEqual(
1609+ old_threads, tree.branch.get_loom_state().get_threads())
1610
1611 def test_revert_loom_on_non_loomed_branch(self):
1612- """We should raise a user-friendly exception if the branch isn't loomed yet."""
1613- self.assert_exception_raised_on_non_loom_branch(['revert-loom', 'foobar'])
1614+ """We should raise a user-friendly exception if the branch isn't loomed
1615+ yet."""
1616+ self.assert_exception_raised_on_non_loom_branch(
1617+ ['revert-loom', 'foobar'])
1618
1619
1620 class TestCombineThread(TestsWithLooms):
1621@@ -703,10 +717,11 @@
1622
1623 def test_combine_last_thread(self):
1624 """Doing combine thread on the last thread is an error for now."""
1625- tree = self.get_vendor_loom()
1626+ self.get_vendor_loom()
1627 out, err = self.run_bzr(['combine-thread'], retcode=3)
1628 self.assertEqual('', out)
1629- self.assertEqual('brz: ERROR: Cannot combine threads on the bottom thread.\n', err)
1630+ self.assertEqual(
1631+ 'brz: ERROR: Cannot combine threads on the bottom thread.\n', err)
1632
1633 def get_two_thread_loom(self):
1634 tree = self.get_vendor_loom()
1635@@ -763,8 +778,10 @@
1636 unique_revid = tree.last_revision()
1637 out, err = self.run_bzr(['combine-thread'], retcode=3)
1638 self.assertEqual('', out)
1639- self.assertEqual("brz: ERROR: "
1640-"Thread 'unique-thread' has unmerged work. Use --force to combine anyway.\n",
1641+ self.assertEqual(
1642+ "brz: ERROR: "
1643+ "Thread 'unique-thread' has unmerged work. "
1644+ "Use --force to combine anyway.\n",
1645 err)
1646 self.assertEqual(unique_revid, tree.last_revision())
1647 self.assertEqual('unique-thread', tree.branch.nick)
1648@@ -772,9 +789,9 @@
1649 def test_combine_last_two_threads(self):
1650 """Doing a combine on two threads gives you just the bottom one."""
1651 tree, loom_tree = self.get_two_thread_loom()
1652- # now we have a change between the threads, so merge this into the lower
1653- # thread to simulate real-world - different rev ids, and the lower
1654- # thread has merged the upper.
1655+ # now we have a change between the threads, so merge this into the
1656+ # lower thread to simulate real-world - different rev ids, and the
1657+ # lower thread has merged the upper.
1658 # ugh, should make merge easier to use.
1659 self.run_bzr(['merge', '-r', 'thread:above-vendor', '.'])
1660 vendor_revid = tree.commit('merge in the above-vendor work.')
1661@@ -798,7 +815,8 @@
1662 self.assertEqual(b'above-vendor-1', tree.last_revision())
1663
1664 def test_combine_thread_on_non_loomed_branch(self):
1665- """We should raise a user-friendly exception if the branch isn't loomed yet."""
1666+ """We should raise a user-friendly exception if the branch isn't loomed
1667+ yet."""
1668 self.assert_exception_raised_on_non_loom_branch(['combine-thread'])
1669
1670
1671@@ -807,10 +825,10 @@
1672
1673 def test_export_loom_no_args(self):
1674 """Test exporting with no arguments"""
1675- tree = self.get_vendor_loom()
1676+ self.get_vendor_loom()
1677 err = self.run_bzr(['export-loom'], retcode=3)[1]
1678- self.assertContainsRe(err,
1679- 'brz: ERROR: No export root known or specified.')
1680+ self.assertContainsRe(
1681+ err, 'brz: ERROR: No export root known or specified.')
1682
1683 def test_export_loom_config(self):
1684 tree = self.get_vendor_loom()
1685@@ -820,6 +838,6 @@
1686
1687 def test_export_loom_path(self):
1688 """Test exporting with specified path"""
1689- tree = self.get_vendor_loom()
1690+ self.get_vendor_loom()
1691 self.run_bzr(['export-loom', 'export-path'])
1692- branch = breezy.branch.Branch.open('export-path/vendor')
1693+ breezy.branch.Branch.open('export-path/vendor')
1694
1695=== modified file 'tests/test_branch.py'
1696--- tests/test_branch.py 2019-08-22 19:36:40 +0000
1697+++ tests/test_branch.py 2022-08-19 17:04:03 +0000
1698@@ -1,19 +1,19 @@
1699 # Loom, a plugin for bzr to assist in developing focused patches.
1700 # Copyright (C) 2006 Canonical Limited.
1701-#
1702+#
1703 # This program is free software; you can redistribute it and/or modify
1704 # it under the terms of the GNU General Public License version 2 as published
1705 # by the Free Software Foundation.
1706-#
1707+#
1708 # This program is distributed in the hope that it will be useful,
1709 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1710 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1711 # GNU General Public License for more details.
1712-#
1713+#
1714 # You should have received a copy of the GNU General Public License
1715 # along with this program; if not, write to the Free Software
1716 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717-#
1718+#
1719
1720
1721 """Tests of the loom Branch related routines."""
1722@@ -49,11 +49,10 @@
1723 bzrdir = self.make_controldir('.')
1724 bzrdir.create_repository()
1725 format = breezy.plugins.loom.branch.BzrBranchLoomFormat1()
1726- branch = format.initialize(bzrdir)
1727+ format.initialize(bzrdir)
1728 self.assertFileEqual('Loom current 1\n\n', '.bzr/branch/last-loom')
1729
1730
1731-
1732 class StubFormat(object):
1733
1734 def network_name(self):
1735@@ -145,21 +144,24 @@
1736 def test_loomify_branch_format_5(self):
1737 branch = self.make_branch('.', format='dirstate')
1738 loomify(branch)
1739- self.assertConvertedBranchFormat(branch,
1740+ self.assertConvertedBranchFormat(
1741+ branch,
1742 breezy.plugins.loom.branch.LoomBranch,
1743 breezy.plugins.loom.branch.BzrBranchLoomFormat1)
1744
1745 def test_loomify_branch_format_6(self):
1746 branch = self.make_branch('.', format='dirstate-tags')
1747 loomify(branch)
1748- self.assertConvertedBranchFormat(branch,
1749+ self.assertConvertedBranchFormat(
1750+ branch,
1751 breezy.plugins.loom.branch.LoomBranch6,
1752 breezy.plugins.loom.branch.BzrBranchLoomFormat6)
1753
1754 def test_loomify_branch_format_7(self):
1755 branch = self.make_branch('.', format='1.6')
1756 loomify(branch)
1757- self.assertConvertedBranchFormat(branch,
1758+ self.assertConvertedBranchFormat(
1759+ branch,
1760 breezy.plugins.loom.branch.LoomBranch7,
1761 breezy.plugins.loom.branch.BzrBranchLoomFormat7)
1762
1763@@ -189,7 +191,8 @@
1764 def test_new_thread_no_duplicate_names(self):
1765 branch = self.make_loom('.')
1766 branch.new_thread('foo')
1767- self.assertRaises(breezy.plugins.loom.branch.DuplicateThreadName,
1768+ self.assertRaises(
1769+ breezy.plugins.loom.branch.DuplicateThreadName,
1770 branch.new_thread, 'foo')
1771 self.assertEqual(
1772 [('foo', EMPTY_REVISION, [])],
1773@@ -198,7 +201,7 @@
1774 def get_tree_with_one_commit(self, path='.'):
1775 """Get a tree with a commit in loom format."""
1776 tree = self.get_tree_with_loom(path=path)
1777- rev_id = tree.commit('first post')
1778+ tree.commit('first post')
1779 return tree
1780
1781 def test_new_thread_with_commits(self):
1782@@ -249,12 +252,12 @@
1783 tree.commit('change something', allow_pointless=True)
1784 self.assertEqual(
1785 [('baseline', first_rev, []),
1786- ('tail', first_rev, [])],
1787+ ('tail', first_rev, [])],
1788 tree.branch.get_loom_state().get_threads())
1789 tree.branch.record_thread('baseline', tree.last_revision())
1790 self.assertEqual(
1791- [('baseline', tree.last_revision(), []),
1792- ('tail', first_rev, [])],
1793+ [('baseline', tree.last_revision(), []),
1794+ ('tail', first_rev, [])],
1795 tree.branch.get_loom_state().get_threads())
1796 self.assertEqual([], tree.branch.loom_parents())
1797 finally:
1798@@ -268,9 +271,10 @@
1799
1800 def test_sprout_empty_loom(self):
1801 source_tree = self.get_tree_with_loom('source')
1802- target_tree = source_tree.controldir.sprout('target').open_workingtree()
1803+ target_dir = source_tree.controldir.sprout('target')
1804+ target_tree = target_dir.open_workingtree()
1805 self.assertLoomSproutedOk(source_tree, target_tree)
1806-
1807+
1808 def test_clone_nonempty_loom_top(self):
1809 """Cloning a nonempty loom at the top should preserve the loom."""
1810 source_tree = self.get_tree_with_one_commit('source')
1811@@ -297,7 +301,8 @@
1812 # now clone from the 'default url' - transport_server rather than
1813 # vfs_server.
1814 source_branch = Branch.open(self.get_url('source'))
1815- target_tree = source_branch.controldir.sprout('target').open_workingtree()
1816+ target_dir = source_branch.controldir.sprout('target')
1817+ target_tree = target_dir.open_workingtree()
1818 self.assertLoomSproutedOk(source_tree, target_tree)
1819
1820 def test_sprout_remote_loom(self):
1821@@ -315,12 +320,13 @@
1822 source_tree.branch.record_loom('commit to loom')
1823 LoomTreeDecorator(source_tree).down_thread()
1824 # now sprout
1825- target_tree = source_tree.controldir.sprout('target').open_workingtree()
1826+ target_dir = source_tree.controldir.sprout('target')
1827+ target_tree = target_dir.open_workingtree()
1828 self.assertLoomSproutedOk(source_tree, target_tree)
1829
1830 def assertLoomSproutedOk(self, source_tree, target_tree):
1831 """A sprout resets the loom to the top to ensure up-thread works.
1832-
1833+
1834 Due to the calls made, this will ensure the loom content has been
1835 pulled, and that the tree state is correct.
1836 """
1837@@ -391,7 +397,7 @@
1838 for rev_id in loom_rev_ids:
1839 self.assertTrue(target.repository.has_revision(rev_id))
1840 self.assertEqual(source.branch.loom_parents(), target.loom_parents())
1841-
1842+
1843 def test_pull_into_empty_loom(self):
1844 """Doing a pull into a loom with no loom revisions works."""
1845 self.pull_into_empty_loom()
1846@@ -522,7 +528,7 @@
1847 # the threads list should be restored
1848 self.assertEqual([], tree.branch.get_loom_state().get_threads())
1849 self.assertEqual(last_rev, tree.branch.last_revision())
1850-
1851+
1852 def test_revert_loom_changes_current_thread_history(self):
1853 tree = self.get_tree_with_loom()
1854 # new threads
1855@@ -599,8 +605,7 @@
1856 tree.branch.revert_thread('bar')
1857 self.assertEqual(
1858 [('foo', EMPTY_REVISION, [EMPTY_REVISION]),
1859- ('bar', EMPTY_REVISION, [EMPTY_REVISION]),
1860- ],
1861+ ('bar', EMPTY_REVISION, [EMPTY_REVISION])],
1862 tree.branch.get_loom_state().get_threads())
1863 self.assertTrue(NULL_REVISION, tree.branch.last_revision())
1864
1865@@ -675,7 +680,6 @@
1866 def test_export_loom_as_branch(self):
1867 tree = self.get_multi_threaded()
1868 tree.branch.controldir.root_transport.mkdir('root')
1869- root_path = tree.branch.controldir.root_transport.local_abspath('root')
1870 repo = self.make_repository('root', shared=True)
1871 repo.set_make_working_trees(False)
1872 root_transport = get_transport('root')
1873
1874=== modified file 'tests/test_loom_io.py'
1875--- tests/test_loom_io.py 2019-08-22 19:36:40 +0000
1876+++ tests/test_loom_io.py 2022-08-19 17:04:03 +0000
1877@@ -1,19 +1,19 @@
1878 # Loom, a plugin for bzr to assist in developing focused patches.
1879 # Copyright (C) 2006 Canonical Limited.
1880-#
1881+#
1882 # This program is free software; you can redistribute it and/or modify
1883 # it under the terms of the GNU General Public License version 2 as published
1884 # by the Free Software Foundation.
1885-#
1886+#
1887 # This program is distributed in the hope that it will be useful,
1888 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1889 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1890 # GNU General Public License for more details.
1891-#
1892+#
1893 # You should have received a copy of the GNU General Public License
1894 # along with this program; if not, write to the Free Software
1895 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1896-#
1897+#
1898
1899
1900 """Tests of the Loom parse and serialise routines."""
1901@@ -22,12 +22,10 @@
1902 from io import BytesIO
1903
1904 import breezy
1905-import breezy.errors as errors
1906 import breezy.osutils
1907 from breezy.plugins.loom.branch import EMPTY_REVISION
1908 import breezy.plugins.loom.loom_io as loom_io
1909 import breezy.plugins.loom.loom_state as loom_state
1910-from breezy.plugins.loom.tree import LoomTreeDecorator
1911 import breezy.revision
1912 from breezy.tests import TestCase
1913
1914@@ -35,9 +33,9 @@
1915 class TestLoomIO(TestCase):
1916
1917 def test_writer_constructors(self):
1918- writer = loom_io.LoomWriter()
1919+ loom_io.LoomWriter()
1920 state = loom_state.LoomState()
1921- writer = loom_io.LoomStateWriter(state)
1922+ loom_io.LoomStateWriter(state)
1923
1924 def assertWritesThreadsCorrectly(self, expected_stream, threads):
1925 """Write threads through a LoomWriter and check the output and sha1."""
1926@@ -109,7 +107,7 @@
1927 b' : baserev base \n'
1928 b' : \xc3\xa9toprev \xc3\xadtop\n',
1929 state)
1930-
1931+
1932 def test_write_state_with_threads_and_parents(self):
1933 state = loom_state.LoomState()
1934 state.set_threads(
1935@@ -139,7 +137,7 @@
1936 loom_io._CURRENT_LOOM_FORMAT_STRING + b'\n'
1937 b'\n'
1938 b' : baserev base \n'
1939- b' : \xc3\xa9toprev \xc3\xadtop\n') # yes this is utf8
1940+ b' : \xc3\xa9toprev \xc3\xadtop\n') # yes this is utf8
1941 self.assertReadState(
1942 [],
1943 [('base ', b'baserev', []),
1944@@ -147,7 +145,7 @@
1945 (u'\xedtop', b'\xc3\xa9toprev', []),
1946 ],
1947 state_stream)
1948-
1949+
1950 def test_read_state_parents(self):
1951 state_stream = BytesIO(
1952 loom_io._CURRENT_LOOM_FORMAT_STRING + b'\n'
1953@@ -162,7 +160,7 @@
1954 loom_io._CURRENT_LOOM_FORMAT_STRING + b'\n'
1955 b'1 2\xc3\xab\n'
1956 b' : baserev base \n'
1957- b' : \xc3\xa9toprev \xc3\xadtop\n') # yes this is utf8
1958+ b' : \xc3\xa9toprev \xc3\xadtop\n') # yes this is utf8
1959 self.assertReadState(
1960 [b'1', b'2\xc3\xab'],
1961 [('base ', b'baserev', [None, None]),
1962
1963=== modified file 'tests/test_loom_state.py'
1964--- tests/test_loom_state.py 2019-08-22 19:36:40 +0000
1965+++ tests/test_loom_state.py 2022-08-19 17:04:03 +0000
1966@@ -1,19 +1,19 @@
1967 # Loom, a plugin for bzr to assist in developing focused patches.
1968 # Copyright (C) 2006 - 2008 Canonical Limited.
1969-#
1970+#
1971 # This program is free software; you can redistribute it and/or modify
1972 # it under the terms of the GNU General Public License version 2 as published
1973 # by the Free Software Foundation.
1974-#
1975+#
1976 # This program is distributed in the hope that it will be useful,
1977 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1978 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1979 # GNU General Public License for more details.
1980-#
1981+#
1982 # You should have received a copy of the GNU General Public License
1983 # along with this program; if not, write to the Free Software
1984 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1985-#
1986+#
1987
1988
1989 """Tests of the Loom current-state object."""
1990@@ -21,12 +21,8 @@
1991
1992 from io import BytesIO
1993
1994-import breezy
1995-import breezy.errors as errors
1996-import breezy.osutils
1997 import breezy.plugins.loom.loom_io as loom_io
1998 import breezy.plugins.loom.loom_state as loom_state
1999-from breezy.plugins.loom.tree import LoomTreeDecorator
2000 from breezy.revision import NULL_REVISION
2001 from breezy.tests import TestCase
2002
2003@@ -44,7 +40,9 @@
2004 def test_reader_constructor(self):
2005 # make a state
2006 state = loom_state.LoomState()
2007- state.set_threads([('name', b'rev', [None, None]), ('dangerous name', b'rev2', [None, None])])
2008+ state.set_threads(
2009+ [('name', b'rev', [None, None]),
2010+ ('dangerous name', b'rev2', [None, None])])
2011 state.set_parents([b'bar', b'am'])
2012 stream = BytesIO()
2013 writer = loom_io.LoomStateWriter(state)
2014
2015=== modified file 'tests/test_revspec.py'
2016--- tests/test_revspec.py 2018-05-20 13:59:05 +0000
2017+++ tests/test_revspec.py 2022-08-19 17:04:03 +0000
2018@@ -1,19 +1,19 @@
2019 # Loom, a plugin for bzr to assist in developing focused patches.
2020 # Copyright (C) 2006 Canonical Limited.
2021-#
2022+#
2023 # This program is free software; you can redistribute it and/or modify
2024 # it under the terms of the GNU General Public License version 2 as published
2025 # by the Free Software Foundation.
2026-#
2027+#
2028 # This program is distributed in the hope that it will be useful,
2029 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2030 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2031 # GNU General Public License for more details.
2032-#
2033+#
2034 # You should have received a copy of the GNU General Public License
2035 # along with this program; if not, write to the Free Software
2036 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2037-#
2038+#
2039
2040
2041 """Tests of the loom revision-specifiers."""
2042@@ -42,7 +42,7 @@
2043
2044 class TestThreadRevSpec(TestRevSpec):
2045 """Tests of the ThreadRevisionSpecifier."""
2046-
2047+
2048 def test_thread_colon_at_bottom_errors(self):
2049 tree, loom_tree, rev_id, _ = self.get_two_thread_loom()
2050 loom_tree.down_thread()
2051@@ -76,8 +76,8 @@
2052 def test_thread_on_non_loom_gives_BzrError(self):
2053 tree = self.make_branch_and_tree('.')
2054 spec = RevisionSpec.from_string('thread:')
2055- err = self.assertRaises(breezy.errors.BzrError, spec.as_revision_id,
2056- tree.branch)
2057+ err = self.assertRaises(
2058+ breezy.errors.BzrError, spec.as_revision_id, tree.branch)
2059 self.assertFalse(err.internal_error)
2060
2061
2062@@ -96,8 +96,8 @@
2063 tree, loom_tree, _, rev_id = self.get_two_thread_loom()
2064 loom_tree.down_thread()
2065 spec = RevisionSpec.from_string('below:')
2066- err = self.assertRaises(breezy.errors.BzrError, spec.as_revision_id,
2067- tree.branch)
2068+ err = self.assertRaises(
2069+ breezy.errors.BzrError, spec.as_revision_id, tree.branch)
2070 self.assertFalse(err.internal_error)
2071
2072 def test_below_named_thread(self):
2073@@ -110,6 +110,6 @@
2074 def test_below_on_non_loom_gives_BzrError(self):
2075 tree = self.make_branch_and_tree('.')
2076 spec = RevisionSpec.from_string('below:')
2077- err = self.assertRaises(breezy.errors.BzrError, spec.as_revision_id,
2078- tree.branch)
2079+ err = self.assertRaises(
2080+ breezy.errors.BzrError, spec.as_revision_id, tree.branch)
2081 self.assertFalse(err.internal_error)
2082
2083=== modified file 'tests/test_tree.py'
2084--- tests/test_tree.py 2019-08-22 19:36:40 +0000
2085+++ tests/test_tree.py 2022-08-19 17:04:03 +0000
2086@@ -1,19 +1,19 @@
2087 # Loom, a plugin for bzr to assist in developing focused patches.
2088 # Copyright (C) 2006 Canonical Limited.
2089-#
2090+#
2091 # This program is free software; you can redistribute it and/or modify
2092 # it under the terms of the GNU General Public License version 2 as published
2093 # by the Free Software Foundation.
2094-#
2095+#
2096 # This program is distributed in the hope that it will be useful,
2097 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2098 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2099 # GNU General Public License for more details.
2100-#
2101+#
2102 # You should have received a copy of the GNU General Public License
2103 # along with this program; if not, write to the Free Software
2104 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2105-#
2106+#
2107
2108
2109 """Tests of the loom Tree related routines."""
2110@@ -33,7 +33,7 @@
2111
2112 class TestTreeDecorator(TestCaseWithLoom):
2113 """Tests of the LoomTreeDecorator class."""
2114-
2115+
2116 def get_loom_with_two_threads(self):
2117 tree = self.get_tree_with_loom('source')
2118 tree.branch.new_thread('bottom')
2119@@ -100,7 +100,8 @@
2120 tree.lock_read()
2121 try:
2122 graph = tree.branch.repository.get_graph()
2123- self.assertEqual([top_rev1, bottom_rev1, NULL_REVISION],
2124+ self.assertEqual(
2125+ [top_rev1, bottom_rev1, NULL_REVISION],
2126 [r for (r, ps) in graph.iter_ancestry([top_rev1])])
2127 self.assertEqual([bottom_rev1], tree.get_parent_ids())
2128 finally:
2129@@ -124,7 +125,8 @@
2130 tree.lock_read()
2131 try:
2132 graph = tree.branch.repository.get_graph()
2133- self.assertEqual([top_rev1, bottom_rev1, NULL_REVISION],
2134+ self.assertEqual(
2135+ [top_rev1, bottom_rev1, NULL_REVISION],
2136 [r for (r, ps) in graph.iter_ancestry([top_rev1])])
2137 self.assertEqual([bottom_rev1], tree.get_parent_ids())
2138 finally:
2139@@ -139,7 +141,7 @@
2140 self.build_tree_contents([('source/a', 'a')])
2141 loom_tree.tree.commit('add a')
2142 loom_tree.up_thread()
2143- e = self.assertRaises(errors.BzrCommandError, loom_tree.up_thread)
2144+ e = self.assertRaises(errors.CommandError, loom_tree.up_thread)
2145 self.assertEqual('Cannot move up from the highest thread.', str(e))
2146
2147 def test_up_thread_merge_type(self):
2148@@ -211,9 +213,8 @@
2149
2150 def test_up_many_target_thread_lower(self):
2151 loom_tree = self.get_loom_with_three_threads()
2152- tree = loom_tree.tree
2153 loom_tree.up_many(target_thread='top')
2154- e = self.assertRaises(errors.BzrCommandError,
2155+ e = self.assertRaises(errors.CommandError,
2156 loom_tree.up_many, target_thread='middle')
2157 self.assertEqual('Cannot up-thread to lower thread.', str(e))
2158
2159@@ -228,7 +229,7 @@
2160 loom_tree.revert_loom()
2161 # the tree should be reverted
2162 self.assertEqual(NULL_REVISION, tree.last_revision())
2163- # the current loom should be reverted
2164+ # the current loom should be reverted
2165 # (we assume this means branch.revert_loom was called())
2166 self.assertEqual([], tree.branch.get_loom_state().get_threads())
2167
2168@@ -243,12 +244,12 @@
2169 loom_tree.revert_loom(thread='bar')
2170 # the tree should be reverted
2171 self.assertEqual(NULL_REVISION, tree.last_revision())
2172- # the current loom should be reverted
2173+ # the current loom should be reverted
2174 # (we assume this means branch.revert_loom was called())
2175 self.assertEqual(
2176 [('foo', EMPTY_REVISION, [])],
2177 tree.branch.get_loom_state().get_threads())
2178-
2179+
2180 def test_revert_thread_different_thread(self):
2181 tree = self.get_tree_with_loom(',')
2182 # ensure we have some stuff to revert
2183@@ -261,7 +262,8 @@
2184 # the tree should not be reverted
2185 self.assertNotEqual(NULL_REVISION, tree.last_revision())
2186 # the bottom thread should be reverted
2187- # (we assume this means branch.revert_thread was
2188+ # (we assume this means branch.revert_thread was
2189 # called())
2190- self.assertEqual([('bar', tree.last_revision(), [])],
2191+ self.assertEqual(
2192+ [('bar', tree.last_revision(), [])],
2193 tree.branch.get_loom_state().get_threads())
2194
2195=== modified file 'tree.py'
2196--- tree.py 2018-05-20 13:59:05 +0000
2197+++ tree.py 2022-08-19 17:04:03 +0000
2198@@ -1,19 +1,19 @@
2199 # Loom, a plugin for bzr to assist in developing focused patches.
2200 # Copyright (C) 2006, 2008 Canonical Limited.
2201-#
2202+#
2203 # This program is free software; you can redistribute it and/or modify
2204 # it under the terms of the GNU General Public License version 2 as published
2205 # by the Free Software Foundation.
2206-#
2207+#
2208 # This program is distributed in the hope that it will be useful,
2209 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2210 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2211 # GNU General Public License for more details.
2212-#
2213+#
2214 # You should have received a copy of the GNU General Public License
2215 # along with this program; if not, write to the Free Software
2216 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2217-#
2218+#
2219
2220 """The Loom Tree support routines.
2221
2222@@ -53,15 +53,15 @@
2223
2224 def _check_switch(self):
2225 if self.tree.last_revision() != self.tree.branch.last_revision():
2226- raise breezy.errors.BzrCommandError('Cannot switch threads with an'
2227- ' out-of-date tree. Please run bzr update.')
2228+ raise breezy.errors.CommandError(
2229+ 'Cannot switch threads with an'
2230+ ' out-of-date tree. Please run bzr update.')
2231
2232 def up_thread(self, merge_type=None):
2233 """Move one thread up in the loom."""
2234 with self.lock_write():
2235 self._check_switch()
2236 # set it up:
2237- current_revision = self.tree.last_revision()
2238 threadname = self.tree.branch.nick
2239 threads = self.tree.branch.get_loom_state().get_threads()
2240 old_thread_rev = None
2241@@ -76,7 +76,7 @@
2242 new_thread_name = thread
2243 new_thread_rev = rev
2244 if new_thread_rev is None:
2245- raise breezy.errors.BzrCommandError(
2246+ raise breezy.errors.CommandError(
2247 'Cannot move up from the highest thread.')
2248 graph = self.tree.branch.repository.get_graph()
2249 # special case no-change condition.
2250@@ -94,7 +94,8 @@
2251 merge_controller = breezy.merge.Merger.from_revision_ids(
2252 self.tree, new_thread_rev, revision_graph=graph)
2253 except breezy.errors.UnrelatedBranches:
2254- raise breezy.errors.BzrCommandError('corrupt loom: thread %s'
2255+ raise breezy.errors.CommandError(
2256+ 'corrupt loom: thread %s'
2257 ' has no common ancestor with thread %s'
2258 % (new_thread_name, threadname))
2259 merge_controller.merge_type = merge_type
2260@@ -102,12 +103,13 @@
2261 # change the tree to the revision of the new thread.
2262 parent_trees = []
2263 if new_thread_rev != breezy.revision.NULL_REVISION:
2264- parent_trees.append((new_thread_rev, merge_controller.other_tree))
2265+ parent_trees.append(
2266+ (new_thread_rev, merge_controller.other_tree))
2267 # record the merge if:
2268 # the old thread != new thread (we have something to record)
2269 # and the new thread is not a descendant of old thread
2270- if (old_thread_rev != new_thread_rev and not
2271- graph.is_ancestor(old_thread_rev, new_thread_rev)):
2272+ if (old_thread_rev != new_thread_rev
2273+ and not graph.is_ancestor(old_thread_rev, new_thread_rev)):
2274 basis_tree = self.tree.basis_tree()
2275 basis_tree.lock_read()
2276 parent_trees.append((old_thread_rev, basis_tree))
2277@@ -127,9 +129,9 @@
2278 # update the branch nick.
2279 self.tree.branch._set_nick(new_thread_name)
2280 trace.note("Moved to thread '%s'." % new_thread_name)
2281- if (basis_tree is not None and
2282- not result and not
2283- self.tree.changes_from(basis_tree).has_changed()):
2284+ if (basis_tree is not None
2285+ and not result
2286+ and not self.tree.changes_from(basis_tree).has_changed()):
2287 trace.note("This thread is now empty, you may wish to "
2288 'run "bzr combine-thread" to remove it.')
2289 if result != 0:
2290@@ -143,13 +145,13 @@
2291 if target_thread is None:
2292 target_thread = threads[-1][0]
2293 if self.branch.nick == target_thread:
2294- raise breezy.errors.BzrCommandError(
2295+ raise breezy.errors.CommandError(
2296 'Cannot move up from the highest thread.')
2297 else:
2298 upper_thread_i = loom_state.thread_index(target_thread)
2299 lower_thread_i = loom_state.thread_index(self.branch.nick)
2300 if lower_thread_i > upper_thread_i:
2301- raise breezy.errors.BzrCommandError(
2302+ raise breezy.errors.CommandError(
2303 "Cannot up-thread to lower thread.")
2304 while self.branch.nick != target_thread:
2305 old_nick = self.branch.nick
2306@@ -175,9 +177,10 @@
2307 old_thread_rev = threads[old_thread_index][1]
2308 if name is None:
2309 if old_thread_index == 0:
2310- raise breezy.errors.BzrCommandError(
2311+ raise breezy.errors.CommandError(
2312 'Cannot move down from the lowest thread.')
2313- new_thread_name, new_thread_rev, _ = threads[old_thread_index - 1]
2314+ new_thread_name, new_thread_rev, _ = (
2315+ threads[old_thread_index - 1])
2316 else:
2317 new_thread_name = name
2318 index = state.thread_index(name)
2319@@ -198,14 +201,16 @@
2320 except breezy.errors.NoSuchRevisionInTree:
2321 basis_tree = repository.revision_tree(old_thread_rev)
2322 to_tree = repository.revision_tree(new_thread_rev)
2323- result = breezy.merge.merge_inner(self.tree.branch,
2324+ result = breezy.merge.merge_inner(
2325+ self.tree.branch,
2326 to_tree,
2327 basis_tree,
2328 this_tree=self.tree)
2329- branch_revno, branch_revision = self.tree.branch.last_revision_info()
2330+ branch_revno, branch_revision = (
2331+ self.tree.branch.last_revision_info())
2332 graph = repository.get_graph()
2333- new_thread_revno = graph.find_distance_to_null(new_thread_rev,
2334- [(branch_revision, branch_revno)])
2335+ new_thread_revno = graph.find_distance_to_null(
2336+ new_thread_rev, [(branch_revision, branch_revno)])
2337 self.tree.branch.set_last_revision_info(new_thread_revno,
2338 new_thread_rev)
2339 if new_thread_rev == breezy.revision.NULL_REVISION:
2340@@ -232,14 +237,12 @@
2341 current_thread = self.branch.nick
2342 last_rev = self.tree.last_revision()
2343 state = self.branch.get_loom_state()
2344- old_threads = state.get_threads()
2345 current_thread_rev = self.branch.last_revision()
2346 if thread is None:
2347 self.branch.revert_loom()
2348 else:
2349 self.branch.revert_thread(thread)
2350 state = self.branch.get_loom_state()
2351- threads = state.get_threads()
2352 threads_dict = state.get_threads_dict()
2353 # TODO find the next up thread if needed
2354 if not threads_dict:
2355@@ -258,9 +261,11 @@
2356 if to_rev == EMPTY_REVISION:
2357 to_rev = breezy.revision.NULL_REVISION
2358 # the thread changed, do a merge to match.
2359- basis_tree = self.tree.branch.repository.revision_tree(current_thread_rev)
2360+ basis_tree = self.tree.branch.repository.revision_tree(
2361+ current_thread_rev)
2362 to_tree = self.tree.branch.repository.revision_tree(to_rev)
2363- result = breezy.merge.merge_inner(self.tree.branch,
2364+ breezy.merge.merge_inner(
2365+ self.tree.branch,
2366 to_tree,
2367 basis_tree,
2368 this_tree=self.tree)
2369
2370=== modified file 'version.py'
2371--- version.py 2019-08-22 19:39:25 +0000
2372+++ version.py 2022-08-19 17:04:03 +0000
2373@@ -1,15 +1,15 @@
2374 # Loom, a plugin for bzr to assist in developing focused patches.
2375 # Copyright (C) 2010 Canonical Limited.
2376-#
2377+#
2378 # This program is free software; you can redistribute it and/or modify
2379 # it under the terms of the GNU General Public License version 2 as published
2380 # by the Free Software Foundation.
2381-#
2382+#
2383 # This program is distributed in the hope that it will be useful,
2384 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2385 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2386 # GNU General Public License for more details.
2387-#
2388+#
2389 # You should have received a copy of the GNU General Public License
2390 # along with this program; if not, write to the Free Software
2391 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Subscribers

People subscribed via source and target branches

to all changes: