/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 breezy/info.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    bzrdir,
35
35
    )
36
36
from .errors import (NoWorkingTree, NotBranchError,
37
 
                           NoRepositoryPresent, NotLocalUrl)
 
37
                     NoRepositoryPresent, NotLocalUrl)
38
38
from .missing import find_unmerged
39
39
 
40
40
 
79
79
 
80
80
    def get_lines(self):
81
81
        max_len = max(len(l) for l, u in self.locs)
82
 
        return ["  %*s: %s\n" % (max_len, l, u) for l, u in self.locs ]
 
82
        return ["  %*s: %s\n" % (max_len, l, u) for l, u in self.locs]
83
83
 
84
84
 
85
85
def gather_location_info(repository=None, branch=None, working=None,
86
 
        control=None):
 
86
                         control=None):
87
87
    locs = {}
88
88
    if branch is not None:
89
89
        branch_path = branch.user_url
162
162
    try:
163
163
        locs.add_url('stacked on', branch.get_stacked_on_url())
164
164
    except (_mod_branch.UnstackableBranchFormat, errors.UnstackableRepositoryFormat,
165
 
        errors.NotStacked):
 
165
            errors.NotStacked):
166
166
        pass
167
167
    return locs
168
168
 
191
191
    outfile.write('Format:\n')
192
192
    if control:
193
193
        outfile.write('       control: %s\n' %
194
 
            control._format.get_format_description())
 
194
                      control._format.get_format_description())
195
195
    if working:
196
196
        outfile.write('  working tree: %s\n' %
197
 
            working._format.get_format_description())
 
197
                      working._format.get_format_description())
198
198
    if branch:
199
199
        outfile.write('        branch: %s\n' %
200
 
            branch._format.get_format_description())
 
200
                      branch._format.get_format_description())
201
201
    if repository:
202
202
        outfile.write('    repository: %s\n' %
203
 
            repository._format.get_format_description())
 
203
                      repository._format.get_format_description())
204
204
 
205
205
 
206
206
def _show_locking_info(repository=None, branch=None, working=None,
207
 
        outfile=None):
 
207
                       outfile=None):
208
208
    """Show locking status of working, branch and repository."""
209
209
    if (repository and repository.get_physical_lock_status() or
210
210
        (branch and branch.get_physical_lock_status()) or
211
 
        (working and working.get_physical_lock_status())):
 
211
            (working and working.get_physical_lock_status())):
212
212
        outfile.write('\n')
213
213
        outfile.write('Lock status:\n')
214
214
        if working:
240
240
        if remote_extra:
241
241
            outfile.write('\n')
242
242
            outfile.write(('Branch is out of date: missing %d '
243
 
                'revision%s.\n') % (len(remote_extra),
244
 
                plural(len(remote_extra))))
 
243
                           'revision%s.\n') % (len(remote_extra),
 
244
                                               plural(len(remote_extra))))
245
245
 
246
246
 
247
247
def _show_missing_revisions_working(working, outfile):
262
262
        missing_count = branch_revno - tree_last_revno
263
263
        outfile.write('\n')
264
264
        outfile.write(('Working tree is out of date: missing %d '
265
 
            'revision%s.\n') % (missing_count, plural(missing_count)))
 
265
                       'revision%s.\n') % (missing_count, plural(missing_count)))
266
266
 
267
267
 
268
268
def _show_working_stats(working, outfile):
292
292
        if entry.kind == 'directory' and path != '':
293
293
            dir_cnt += 1
294
294
    outfile.write('  %8d versioned %s\n' % (dir_cnt,
295
 
        plural(dir_cnt, 'subdirectory', 'subdirectories')))
 
295
                                            plural(dir_cnt, 'subdirectory', 'subdirectories')))
296
296
 
297
297
 
298
298
def _show_branch_stats(branch, verbose, outfile):
308
308
    if verbose:
309
309
        committers = stats['committers']
310
310
        outfile.write('  %8d committer%s\n' % (committers,
311
 
            plural(committers)))
 
311
                                               plural(committers)))
312
312
    if revno:
313
313
        timestamp, timezone = stats['firstrev']
314
314
        age = int((time.time() - timestamp) / 3600 / 24)
315
315
        outfile.write('  %8d day%s old\n' % (age, plural(age)))
316
316
        outfile.write('   first revision: %s\n' %
317
 
            osutils.format_date(timestamp, timezone))
 
317
                      osutils.format_date(timestamp, timezone))
318
318
        timestamp, timezone = stats['latestrev']
319
319
        outfile.write('  latest revision: %s\n' %
320
 
            osutils.format_date(timestamp, timezone))
 
320
                      osutils.format_date(timestamp, timezone))
321
321
    return stats
322
322
 
323
323
 
326
326
    if repository.make_working_trees():
327
327
        outfile.write('\n')
328
328
        outfile.write('Create working tree for new branches inside '
329
 
            'the repository.\n')
 
329
                      'the repository.\n')
330
330
 
331
331
 
332
332
def _show_repository_stats(repository, stats, outfile):
336
336
        revisions = stats['revisions']
337
337
        f.write('  %8d revision%s\n' % (revisions, plural(revisions)))
338
338
    if 'size' in stats:
339
 
        f.write('  %8d KiB\n' % (stats['size']/1024))
 
339
        f.write('  %8d KiB\n' % (stats['size'] / 1024))
340
340
    for hook in hooks['repository']:
341
341
        hook(repository, stats, f)
342
342
    if f.getvalue() != "":
384
384
 
385
385
 
386
386
def show_component_info(control, repository, branch=None, working=None,
387
 
    verbose=1, outfile=None):
 
387
                        verbose=1, outfile=None):
388
388
    """Write info about all bzrdir components to stdout"""
389
389
    if outfile is None:
390
390
        outfile = sys.stdout
397
397
    outfile.write("%s (format: %s)\n" % (layout, format))
398
398
    _show_location_info(
399
399
        gather_location_info(control=control, repository=repository,
400
 
            branch=branch, working=working),
 
400
                             branch=branch, working=working),
401
401
        outfile)
402
402
    if branch is not None:
403
403
        _show_related_info(branch, outfile)
467
467
            phrase = "branchless tree"
468
468
        else:
469
469
            if (tree is not None and tree.controldir.control_url !=
470
 
                branch.controldir.control_url):
 
470
                    branch.controldir.control_url):
471
471
                independence = ''
472
472
                phrase = "Lightweight checkout"
473
473
            elif branch.get_bound_location() is not None:
490
490
 
491
491
    If no matching candidate is found, "unnamed" is returned.
492
492
    """
493
 
    candidates  = []
 
493
    candidates = []
494
494
    if (branch is not None and tree is not None and
495
 
        branch.user_url != tree.user_url):
 
495
            branch.user_url != tree.user_url):
496
496
        branch = None
497
497
        repository = None
498
498
    non_aliases = set(controldir.format_registry.keys())
501
501
        format = controldir.format_registry.make_controldir(key)
502
502
        if isinstance(format, bzrdir.BzrDirMetaFormat1):
503
503
            if (tree and format.workingtree_format !=
504
 
                tree._format):
 
504
                    tree._format):
505
505
                continue
506
506
            if (branch and format.get_branch_format() !=
507
 
                branch._format):
 
507
                    branch._format):
508
508
                continue
509
509
            if (repository and format.repository_format !=
510
 
                repository._format):
 
510
                    repository._format):
511
511
                continue
512
512
        if format.__class__ is not control._format.__class__:
513
513
            continue
516
516
        return 'unnamed'
517
517
    candidates.sort()
518
518
    new_candidates = [c for c in candidates if not
519
 
        controldir.format_registry.get_info(c).hidden]
 
519
                      controldir.format_registry.get_info(c).hidden]
520
520
    if len(new_candidates) > 0:
521
521
        # If there are any non-hidden formats that match, only return those to
522
522
        # avoid listing hidden formats except when only a hidden format will
531
531
    def __init__(self):
532
532
        super(InfoHooks, self).__init__("breezy.info", "hooks")
533
533
        self.add_hook('repository',
534
 
            "Invoked when displaying the statistics for a repository. "
535
 
            "repository is called with a statistics dictionary as returned "
536
 
            "by the repository and a file-like object to write to.", (1, 15))
 
534
                      "Invoked when displaying the statistics for a repository. "
 
535
                      "repository is called with a statistics dictionary as returned "
 
536
                      "by the repository and a file-like object to write to.", (1, 15))
537
537
 
538
538
 
539
539
hooks = InfoHooks()