189
189
# The URL is a repository. If it successfully upgrades,
190
# then upgrade the dependent branches and trees as well.
190
# then upgrade the dependent branches as well.
191
191
if repo.is_shared():
192
dependents = _find_repo_dependents(repo)
192
dependents = repo.find_branches()
194
194
# Do the conversions
195
195
attempted = [control_dir]
196
196
succeeded, exceptions = _convert_items([control_dir], format, clean_up,
197
197
pack, dry_run, verbose=dependents)
198
198
if succeeded and dependents:
199
branches, trees = dependents
200
note("Found %d dependents: %d branches, %d trees - upgrading ...",
201
len(dependents), len(branches), len(trees))
199
note("Found %d dependent branches - upgrading ...", len(dependents))
203
201
# Convert dependent branches
204
branch_cdirs = [b.bzrdir for b in branches]
202
branch_cdirs = [b.bzrdir for b in dependents]
205
203
successes, problems = _convert_items(branch_cdirs, format, clean_up,
206
204
pack, dry_run, label="branch")
207
205
attempted.extend(branch_cdirs)
208
206
succeeded.extend(successes)
209
207
exceptions.extend(problems)
211
# Convert dependent trees
212
# TODO: Filter trees so that we don't attempt to convert trees
213
# referring to branches that failed.
214
tree_cdirs = [t.bzrdir for t in trees]
215
successes, problems = _convert_items(tree_cdirs, format, clean_up,
216
pack, dry_run, label="tree")
217
attempted.extend(tree_cdirs)
218
succeeded.extend(successes)
219
exceptions.extend(problems)
221
209
# Return the result
222
210
return attempted, succeeded, exceptions
288
# TODO: move this helper method into repository.py once it supports trees ...
289
def _find_repo_dependents(repo):
290
"""Find the branches using a shared repository and trees using the branches.
292
:return: (branches, trees) or None if none.
294
# TODO: find trees (lightweight checkouts), not just branches
295
branches = repo.find_branches()
297
return (branches, [])