/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: Vincent Ladeuil
  • Date: 2011-11-18 07:29:20 UTC
  • mfrom: (6277 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6278.
  • Revision ID: v.ladeuil+lp@free.fr-20111118072920-76q1ho772bkmnno2
Merge trunk to resolve news conflict

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        return ["  %*s: %s\n" % (max_len, l, u) for l, u in self.locs ]
78
78
 
79
79
 
80
 
def gather_location_info(repository, branch=None, working=None):
 
80
def gather_location_info(repository=None, branch=None, working=None,
 
81
        control=None):
81
82
    locs = {}
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()
88
88
    else:
89
89
        branch_path = None
90
90
        master_path = None
 
91
        try:
 
92
            if control is not None and control.get_branch_reference():
 
93
                locs['checkout of branch'] = control.get_branch_reference()
 
94
        except NotBranchError:
 
95
            pass
91
96
    if working:
92
97
        working_path = working.user_url
93
98
        if working_path != branch_path:
106
111
            locs['branch root'] = branch_path
107
112
    else:
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:
114
119
            # standalone
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
116
125
        else:
117
 
            locs['repository'] = repository_path
 
126
            # Really, at least a control directory should be
 
127
            # passed in for this method to be useful.
 
128
            pass
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]
335
347
    try:
336
348
        tree = a_bzrdir.open_workingtree(
337
349
            recommend_upgrade=False)
338
 
    except (NoWorkingTree, NotLocalUrl):
 
350
    except (NoWorkingTree, NotLocalUrl, NotBranchError):
339
351
        tree = None
340
352
        try:
341
353
            branch = a_bzrdir.open_branch()
344
356
            try:
345
357
                repository = a_bzrdir.open_repository()
346
358
            except NoRepositoryPresent:
347
 
                # Return silently; cmd_info already returned NotBranchError
348
 
                # if no controldir could be opened.
349
 
                return
 
359
                lockable = None
 
360
                repository = None
350
361
            else:
351
362
                lockable = repository
352
363
        else:
357
368
        repository = branch.repository
358
369
        lockable = tree
359
370
 
360
 
    lockable.lock_read()
 
371
    if lockable is not None:
 
372
        lockable.lock_read()
361
373
    try:
362
374
        show_component_info(a_bzrdir, repository, branch, tree, verbose,
363
375
                            outfile)
364
376
    finally:
365
 
        lockable.unlock()
 
377
        if lockable is not None:
 
378
            lockable.unlock()
366
379
 
367
380
 
368
381
def show_component_info(control, repository, branch=None, working=None,
374
387
        verbose = 1
375
388
    if verbose is True:
376
389
        verbose = 2
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),
381
 
                        outfile)
 
393
    _show_location_info(
 
394
        gather_location_info(control=control, repository=repository,
 
395
            branch=branch, working=working),
 
396
        outfile)
382
397
    if branch is not None:
383
398
        _show_related_info(branch, outfile)
384
399
    if verbose == 0:
403
418
    _show_repository_stats(repository, stats, outfile)
404
419
 
405
420
 
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
408
423
 
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"
412
427
    """
 
428
    if branch is None and control is not None:
 
429
        try:
 
430
            branch_reference = control.get_branch_reference()
 
431
        except NotBranchError:
 
432
            pass
 
433
        else:
 
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: