Merge lp:~jelmer/brz/iter-branch into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/iter-branch
Merge into: lp:brz
Diff against target: 103 lines (+15/-10)
5 files modified
breezy/check.py (+1/-1)
breezy/repository.py (+7/-5)
breezy/tests/per_repository/test_repository.py (+3/-3)
breezy/upgrade.py (+1/-1)
doc/en/release-notes/brz-3.1.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/iter-branch
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+369369@code.launchpad.net

Commit message

Make Repository.find_branches an iterator.

Description of the change

Make Repository.find_branches an iterator.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/check.py'
2--- breezy/check.py 2018-11-11 04:08:32 +0000
3+++ breezy/check.py 2019-07-07 17:24:41 +0000
4@@ -119,7 +119,7 @@
5 if repo is not None:
6 repo.lock_read()
7 to_unlock.append(repo)
8- branches = repo.find_branches(using=True)
9+ branches = list(repo.find_branches(using=True))
10 saw_tree = False
11 if do_branch or do_tree:
12 for branch in branches:
13
14=== modified file 'breezy/repository.py'
15--- breezy/repository.py 2019-06-02 05:13:10 +0000
16+++ breezy/repository.py 2019-07-07 17:24:41 +0000
17@@ -564,7 +564,9 @@
18 :param using: If True, list only branches using this repository.
19 """
20 if using and not self.is_shared():
21- return self.controldir.list_branches()
22+ for branch in self.controldir.list_branches():
23+ yield branch
24+ return
25
26 class Evaluator(object):
27
28@@ -585,14 +587,14 @@
29 value = (controldir.list_branches(), None)
30 return True, value
31
32- ret = []
33 for branches, repository in controldir.ControlDir.find_controldirs(
34 self.user_transport, evaluate=Evaluator()):
35 if branches is not None:
36- ret.extend(branches)
37+ for branch in branches:
38+ yield branch
39 if not using and repository is not None:
40- ret.extend(repository.find_branches())
41- return ret
42+ for branch in repository.find_branches():
43+ yield branch
44
45 def search_missing_revision_ids(self, other,
46 find_ghosts=True, revision_ids=None, if_present_ids=None,
47
48=== modified file 'breezy/tests/per_repository/test_repository.py'
49--- breezy/tests/per_repository/test_repository.py 2019-02-01 16:56:56 +0000
50+++ breezy/tests/per_repository/test_repository.py 2019-07-07 17:24:41 +0000
51@@ -800,7 +800,7 @@
52
53 def test_find_branches(self):
54 repo = self.make_repository_and_foo_bar()
55- branches = repo.find_branches()
56+ branches = list(repo.find_branches())
57 self.assertContainsRe(branches[-1].base, 'repository/foo/$')
58 self.assertContainsRe(branches[-3].base, 'repository/baz/qux/$')
59 self.assertContainsRe(branches[-2].base, 'repository/baz/qux/quxx/$')
60@@ -818,7 +818,7 @@
61 repo = self.make_repository_and_foo_bar(shared=True)
62 except errors.IncompatibleFormat:
63 raise tests.TestNotApplicable
64- branches = repo.find_branches(using=True)
65+ branches = list(repo.find_branches(using=True))
66 self.assertContainsRe(branches[-1].base, 'repository/foo/$')
67 # in some formats, creating a repo creates a branch
68 if len(branches) == 2:
69@@ -847,7 +847,7 @@
70 try:
71 repo.controldir.open_branch()
72 except errors.NotBranchError:
73- self.assertEqual([], repo.find_branches(using=True))
74+ self.assertEqual([], list(repo.find_branches(using=True)))
75 else:
76 self.assertEqual([repo.controldir.root_transport.base],
77 [b.base for b in repo.find_branches(using=True)])
78
79=== modified file 'breezy/upgrade.py'
80--- breezy/upgrade.py 2018-11-11 04:08:32 +0000
81+++ breezy/upgrade.py 2019-07-07 17:24:41 +0000
82@@ -195,7 +195,7 @@
83 # The URL is a repository. If it successfully upgrades,
84 # then upgrade the dependent branches as well.
85 if repo.is_shared():
86- dependents = repo.find_branches(using=True)
87+ dependents = list(repo.find_branches(using=True))
88
89 # Do the conversions
90 attempted = [control_dir]
91
92=== modified file 'doc/en/release-notes/brz-3.1.txt'
93--- doc/en/release-notes/brz-3.1.txt 2019-07-07 16:54:07 +0000
94+++ doc/en/release-notes/brz-3.1.txt 2019-07-07 17:24:41 +0000
95@@ -84,6 +84,9 @@
96 * New ``Tree.get_transform`` method for getting a ``TreeTransform``
97 object. (Jelmer Vernooij)
98
99+* ``Repository.find_branches`` now returns an iterator rather than a
100+ list. (Jelmer Vernooij, #413970)
101+
102 * New ``Tree.get_nested_tree`` method for retrieving a nested tree.
103 (Jelmer Vernooij)
104

Subscribers

People subscribed via source and target branches