/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: Martin
  • Date: 2018-11-16 19:09:31 UTC
  • mfrom: (7175 work)
  • mto: This revision was merged to the branch mainline in revision 7177.
  • Revision ID: gzlist@googlemail.com-20181116190931-rmh7pk2an1zuecby
Merge trunk to resolve conflicts

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):
248
248
    """Show missing revisions in working tree."""
249
249
    branch = working.branch
250
 
    basis = working.basis_tree()
251
250
    try:
252
251
        branch_revno, branch_last_revision = branch.last_revision_info()
253
252
    except errors.UnsupportedOperation:
262
261
        missing_count = branch_revno - tree_last_revno
263
262
        outfile.write('\n')
264
263
        outfile.write(('Working tree is out of date: missing %d '
265
 
            'revision%s.\n') % (missing_count, plural(missing_count)))
 
264
                       'revision%s.\n') % (missing_count, plural(missing_count)))
266
265
 
267
266
 
268
267
def _show_working_stats(working, outfile):
292
291
        if entry.kind == 'directory' and path != '':
293
292
            dir_cnt += 1
294
293
    outfile.write('  %8d versioned %s\n' % (dir_cnt,
295
 
        plural(dir_cnt, 'subdirectory', 'subdirectories')))
 
294
                                            plural(dir_cnt, 'subdirectory', 'subdirectories')))
296
295
 
297
296
 
298
297
def _show_branch_stats(branch, verbose, outfile):
308
307
    if verbose:
309
308
        committers = stats['committers']
310
309
        outfile.write('  %8d committer%s\n' % (committers,
311
 
            plural(committers)))
 
310
                                               plural(committers)))
312
311
    if revno:
313
312
        timestamp, timezone = stats['firstrev']
314
313
        age = int((time.time() - timestamp) / 3600 / 24)
315
314
        outfile.write('  %8d day%s old\n' % (age, plural(age)))
316
315
        outfile.write('   first revision: %s\n' %
317
 
            osutils.format_date(timestamp, timezone))
 
316
                      osutils.format_date(timestamp, timezone))
318
317
        timestamp, timezone = stats['latestrev']
319
318
        outfile.write('  latest revision: %s\n' %
320
 
            osutils.format_date(timestamp, timezone))
 
319
                      osutils.format_date(timestamp, timezone))
321
320
    return stats
322
321
 
323
322
 
326
325
    if repository.make_working_trees():
327
326
        outfile.write('\n')
328
327
        outfile.write('Create working tree for new branches inside '
329
 
            'the repository.\n')
 
328
                      'the repository.\n')
330
329
 
331
330
 
332
331
def _show_repository_stats(repository, stats, outfile):
336
335
        revisions = stats['revisions']
337
336
        f.write('  %8d revision%s\n' % (revisions, plural(revisions)))
338
337
    if 'size' in stats:
339
 
        f.write('  %8d KiB\n' % (stats['size']/1024))
 
338
        f.write('  %8d KiB\n' % (stats['size'] / 1024))
340
339
    for hook in hooks['repository']:
341
340
        hook(repository, stats, f)
342
341
    if f.getvalue() != "":
384
383
 
385
384
 
386
385
def show_component_info(control, repository, branch=None, working=None,
387
 
    verbose=1, outfile=None):
 
386
                        verbose=1, outfile=None):
388
387
    """Write info about all bzrdir components to stdout"""
389
388
    if outfile is None:
390
389
        outfile = sys.stdout
397
396
    outfile.write("%s (format: %s)\n" % (layout, format))
398
397
    _show_location_info(
399
398
        gather_location_info(control=control, repository=repository,
400
 
            branch=branch, working=working),
 
399
                             branch=branch, working=working),
401
400
        outfile)
402
401
    if branch is not None:
403
402
        _show_related_info(branch, outfile)
467
466
            phrase = "branchless tree"
468
467
        else:
469
468
            if (tree is not None and tree.controldir.control_url !=
470
 
                branch.controldir.control_url):
 
469
                    branch.controldir.control_url):
471
470
                independence = ''
472
471
                phrase = "Lightweight checkout"
473
472
            elif branch.get_bound_location() is not None:
490
489
 
491
490
    If no matching candidate is found, "unnamed" is returned.
492
491
    """
493
 
    candidates  = []
 
492
    candidates = []
494
493
    if (branch is not None and tree is not None and
495
 
        branch.user_url != tree.user_url):
 
494
            branch.user_url != tree.user_url):
496
495
        branch = None
497
496
        repository = None
498
497
    non_aliases = set(controldir.format_registry.keys())
501
500
        format = controldir.format_registry.make_controldir(key)
502
501
        if isinstance(format, bzrdir.BzrDirMetaFormat1):
503
502
            if (tree and format.workingtree_format !=
504
 
                tree._format):
 
503
                    tree._format):
505
504
                continue
506
505
            if (branch and format.get_branch_format() !=
507
 
                branch._format):
 
506
                    branch._format):
508
507
                continue
509
508
            if (repository and format.repository_format !=
510
 
                repository._format):
 
509
                    repository._format):
511
510
                continue
512
511
        if format.__class__ is not control._format.__class__:
513
512
            continue
516
515
        return 'unnamed'
517
516
    candidates.sort()
518
517
    new_candidates = [c for c in candidates if not
519
 
        controldir.format_registry.get_info(c).hidden]
 
518
                      controldir.format_registry.get_info(c).hidden]
520
519
    if len(new_candidates) > 0:
521
520
        # If there are any non-hidden formats that match, only return those to
522
521
        # avoid listing hidden formats except when only a hidden format will
530
529
 
531
530
    def __init__(self):
532
531
        super(InfoHooks, self).__init__("breezy.info", "hooks")
533
 
        self.add_hook('repository',
 
532
        self.add_hook(
 
533
            'repository',
534
534
            "Invoked when displaying the statistics for a repository. "
535
535
            "repository is called with a statistics dictionary as returned "
536
536
            "by the repository and a file-like object to write to.", (1, 15))