77
77
return [" %*s: %s\n" % (max_len, l, u) for l, u in self.locs ]
80
def gather_location_info(repository, branch=None, working=None):
80
def gather_location_info(repository=None, branch=None, working=None,
82
repository_path = repository.user_url
83
83
if branch is not None:
84
84
branch_path = branch.user_url
85
85
master_path = branch.get_bound_location()
106
111
locs['branch root'] = branch_path
108
113
working_path = None
109
if repository.is_shared():
114
if repository is not None and repository.is_shared():
110
115
# lightweight checkout of branch in shared repository
111
116
if branch_path is not None:
112
117
locs['repository branch'] = branch_path
113
118
elif branch_path is not None:
115
120
locs['branch root'] = branch_path
121
elif repository is not None:
122
locs['repository'] = repository.user_url
123
elif control is not None:
124
locs['control directory'] = control.user_url
117
locs['repository'] = repository_path
126
# Really, at least a control directory should be
127
# passed in for this method to be useful.
118
129
if master_path != branch_path:
119
130
locs['bound to branch'] = master_path
120
if repository.is_shared():
131
if repository is not None and repository.is_shared():
121
132
# lightweight checkout of branch in shared repository
122
locs['shared repository'] = repository_path
123
order = ['light checkout root', 'repository checkout root',
124
'checkout root', 'checkout of branch', 'shared repository',
133
locs['shared repository'] = repository.user_url
134
order = ['control directory', 'light checkout root',
135
'repository checkout root', 'checkout root',
136
'checkout of branch', 'shared repository',
125
137
'repository', 'repository branch', 'branch root',
126
138
'bound to branch']
127
139
return [(n, locs[n]) for n in order if n in locs]
336
348
tree = a_bzrdir.open_workingtree(
337
349
recommend_upgrade=False)
338
except (NoWorkingTree, NotLocalUrl):
350
except (NoWorkingTree, NotLocalUrl, NotBranchError):
341
353
branch = a_bzrdir.open_branch()
357
368
repository = branch.repository
371
if lockable is not None:
362
374
show_component_info(a_bzrdir, repository, branch, tree, verbose,
377
if lockable is not None:
368
381
def show_component_info(control, repository, branch=None, working=None,
375
388
if verbose is True:
377
layout = describe_layout(repository, branch, working)
390
layout = describe_layout(repository, branch, working, control)
378
391
format = describe_format(control, repository, branch, working)
379
392
outfile.write("%s (format: %s)\n" % (layout, format))
380
_show_location_info(gather_location_info(repository, branch, working),
394
gather_location_info(control=control, repository=repository,
395
branch=branch, working=working),
382
397
if branch is not None:
383
398
_show_related_info(branch, outfile)
403
418
_show_repository_stats(repository, stats, outfile)
406
def describe_layout(repository=None, branch=None, tree=None):
421
def describe_layout(repository=None, branch=None, tree=None, control=None):
407
422
"""Convert a control directory layout into a user-understandable term
409
424
Common outputs include "Standalone tree", "Repository branch" and
410
425
"Checkout". Uncommon outputs include "Unshared repository with trees"
411
426
and "Empty control directory"
428
if branch is None and control is not None:
430
branch_reference = control.get_branch_reference()
431
except NotBranchError:
434
if branch_reference is not None:
435
return "Dangling branch reference"
413
436
if repository is None:
414
437
return 'Empty control directory'
415
438
if branch is None and tree is None: