58
58
result = result.rstrip('/')
62
def _show_location_info(repository, branch=None, working=None):
63
"""Show known locations for working, branch and repository."""
61
class _UrlList(object):
66
def add_url(self, label, url):
67
self.add_path(label, urlutils.unescape_for_display(url, 'ascii'))
69
def add_url(self, label, url):
70
self.add_path(label, url)
72
def add_path(self, label, path):
73
self.urls.append((label, path))
75
def print_lines(self):
76
max_len = max(len(l) for l, u in self.urls)
77
for label, url in self.urls:
78
print " %*s: %s" % (max_len, label, url)
81
def gather_location_info(repository, branch=None, working=None):
64
83
repository_path = repository.bzrdir.root_transport.base
66
if working and branch:
84
if branch is not None:
85
branch_path = branch.bzrdir.root_transport.base
86
master_path = branch.get_bound_location()
87
if master_path is None:
88
master_path = branch_path
67
93
working_path = working.bzrdir.root_transport.base
68
branch_path = branch.bzrdir.root_transport.base
69
94
if working_path != branch_path:
70
# lightweight checkout
71
print ' light checkout root: %s' % working_path
95
locs['light checkout root'] = working_path
96
if master_path != branch_path:
72
97
if repository.is_shared():
73
# lightweight checkout of branch in shared repository
74
print ' shared repository: %s' % repository_path
75
print ' repository branch: %s' % (
76
_repo_rel_url(repository_path, branch_path))
98
locs['repository checkout root'] = branch_path
78
# lightweight checkout of standalone branch
79
print ' checkout of branch: %s' % branch_path
100
locs['checkout root'] = branch_path
101
if working_path != master_path:
102
locs['checkout of branch'] = master_path
80
103
elif repository.is_shared():
81
# branch with tree inside shared repository
82
print ' shared repository: %s' % repository_path
83
print ' repository checkout: %s' % (
84
_repo_rel_url(repository_path, branch_path))
85
elif branch.get_bound_location():
87
print ' checkout root: %s' % working_path
88
print ' checkout of branch: %s' % branch.get_bound_location()
104
locs['repository branch'] = _repo_rel_url(repository_path,
106
elif branch_path is not None:
91
print ' branch root: %s' % working_path
93
branch_path = branch.bzrdir.root_transport.base
108
locs['branch root'] = branch_path
94
111
if repository.is_shared():
95
# branch is part of shared repository
96
print ' shared repository: %s' % repository_path
97
print ' repository branch: %s' % (
98
_repo_rel_url(repository_path, branch_path))
112
# lightweight checkout of branch in shared repository
113
if branch_path is not None:
114
locs['repository branch'] = _repo_rel_url(repository_path,
116
elif branch_path is not None:
118
locs['branch root'] = branch_path
101
print ' branch root: %s' % branch_path
104
assert repository.is_shared()
105
print ' shared repository: %s' % repository_path
120
locs['repository'] = repository_path
121
if repository.is_shared():
122
# lightweight checkout of branch in shared repository
123
locs['shared repository'] = repository_path
127
def _show_location_info(locs):
128
"""Show known locations for working, branch and repository."""
130
path_list = _UrlList()
131
for loc in ['light checkout root', 'repository checkout root',
132
'checkout root', 'checkout of branch', 'shared repository',
133
'repository branch', 'branch root']:
135
path_list.add_url(loc, locs[loc])
138
path_list.print_lines()
108
141
def _show_related_info(branch):