/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/info.py

  • Committer: Aaron Bentley
  • Date: 2007-06-07 01:16:20 UTC
  • mto: This revision was merged to the branch mainline in revision 2528.
  • Revision ID: aaron.bentley@utoronto.ca-20070607011620-if7ko3f86lwsmw3j
Get all tests passing

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        result = result.rstrip('/')
59
59
    return result
60
60
 
61
 
 
62
 
def _show_location_info(repository, branch=None, working=None):
63
 
    """Show known locations for working, branch and repository."""
 
61
class _UrlList(object):
 
62
 
 
63
    def __init__(self):
 
64
        self.urls = []
 
65
 
 
66
    def add_url(self, label, url):
 
67
        self.add_path(label, urlutils.unescape_for_display(url, 'ascii'))
 
68
 
 
69
    def add_url(self, label, url):
 
70
        self.add_path(label, url)
 
71
 
 
72
    def add_path(self, label, path):
 
73
        self.urls.append((label, path))
 
74
 
 
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)
 
79
 
 
80
 
 
81
def gather_location_info(repository, branch=None, working=None):
 
82
    locs = {}
64
83
    repository_path = repository.bzrdir.root_transport.base
65
 
    print 'Location:'
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
 
89
    else:
 
90
        branch_path = None
 
91
        master_path = None
 
92
    if working:
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
77
99
            else:
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():
86
 
            # normal checkout
87
 
            print '       checkout root: %s' % working_path
88
 
            print '  checkout of branch: %s' % branch.get_bound_location()
89
 
        else:
 
104
            locs['repository branch'] = _repo_rel_url(repository_path,
 
105
                branch_path)
 
106
        elif branch_path is not None:
90
107
            # standalone
91
 
            print '  branch root: %s' % working_path
92
 
    elif branch:
93
 
        branch_path = branch.bzrdir.root_transport.base
 
108
            locs['branch root'] = branch_path
 
109
    else:
 
110
        working_path = None
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,
 
115
                                                          branch_path)
 
116
        elif branch_path is not None:
 
117
            # standalone
 
118
            locs['branch root'] = branch_path
99
119
        else:
100
 
            # standalone branch
101
 
            print '  branch root: %s' % branch_path
102
 
    else:
103
 
        # shared repository
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
 
124
    return locs
 
125
 
 
126
 
 
127
def _show_location_info(locs):
 
128
    """Show known locations for working, branch and repository."""
 
129
    print 'Location:'
 
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']:
 
134
        try:
 
135
            path_list.add_url(loc, locs[loc])
 
136
        except KeyError:
 
137
            pass
 
138
    path_list.print_lines()
106
139
 
107
140
 
108
141
def _show_related_info(branch):
308
341
    layout = describe_layout(repository, branch, working)
309
342
    format = describe_format(control, repository, branch, working)
310
343
    print "%s (format: %s)" % (layout, format)
311
 
    _show_location_info(repository, branch, working)
 
344
    _show_location_info(gather_location_info(repository, branch, working))
312
345
    if verbose == 0:
313
346
        return
314
347
    if branch is not None: