/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: John Arbash Meinel
  • Date: 2009-04-21 23:54:16 UTC
  • mto: (4300.1.7 groupcompress_info)
  • mto: This revision was merged to the branch mainline in revision 4301.
  • Revision ID: john@arbash-meinel.com-20090421235416-f0cz6ilf5cufbugi
Fix bug #364900, properly remove the 64kB that was just encoded in the copy.
Also, stop supporting None as a copy length in 'encode_copy_instruction'.
It was only used by the test suite, and it is good to pull that sort of thing out of
production code. (Besides, setting the copy to 64kB has the same effect.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
__all__ = ['show_bzrdir_info']
18
18
 
19
 
from cStringIO import StringIO
 
19
import os
20
20
import time
21
21
import sys
22
22
 
23
23
from bzrlib import (
24
24
    bzrdir,
 
25
    diff,
25
26
    errors,
26
 
    hooks as _mod_hooks,
27
27
    osutils,
28
28
    urlutils,
29
29
    )
78
78
 
79
79
def gather_location_info(repository, branch=None, working=None):
80
80
    locs = {}
81
 
    repository_path = repository.user_url
 
81
    repository_path = repository.bzrdir.root_transport.base
82
82
    if branch is not None:
83
 
        branch_path = branch.user_url
 
83
        branch_path = branch.bzrdir.root_transport.base
84
84
        master_path = branch.get_bound_location()
85
85
        if master_path is None:
86
86
            master_path = branch_path
88
88
        branch_path = None
89
89
        master_path = None
90
90
    if working:
91
 
        working_path = working.user_url
 
91
        working_path = working.bzrdir.root_transport.base
92
92
        if working_path != branch_path:
93
93
            locs['light checkout root'] = working_path
94
94
        if master_path != branch_path:
299
299
            'the repository.\n')
300
300
 
301
301
 
302
 
def _show_repository_stats(repository, stats, outfile):
 
302
def _show_repository_stats(stats, outfile):
303
303
    """Show statistics about a repository."""
304
 
    f = StringIO()
 
304
    if 'revisions' in stats or 'size' in stats:
 
305
        outfile.write('\n')
 
306
        outfile.write('Repository:\n')
305
307
    if 'revisions' in stats:
306
308
        revisions = stats['revisions']
307
 
        f.write('  %8d revision%s\n' % (revisions, plural(revisions)))
 
309
        outfile.write('  %8d revision%s\n' % (revisions, plural(revisions)))
308
310
    if 'size' in stats:
309
 
        f.write('  %8d KiB\n' % (stats['size']/1024))
310
 
    for hook in hooks['repository']:
311
 
        hook(repository, stats, f)
312
 
    if f.getvalue() != "":
313
 
        outfile.write('\n')
314
 
        outfile.write('Repository:\n')
315
 
        outfile.write(f.getvalue())
 
311
        outfile.write('  %8d KiB\n' % (stats['size']/1024))
316
312
 
317
313
 
318
314
def show_bzrdir_info(a_bzrdir, verbose=False, outfile=None):
386
382
        stats = repository.gather_stats()
387
383
    if branch is None and working is None:
388
384
        _show_repository_info(repository, outfile)
389
 
    _show_repository_stats(repository, stats, outfile)
 
385
    _show_repository_stats(stats, outfile)
390
386
 
391
387
 
392
388
def describe_layout(repository=None, branch=None, tree=None):
418
414
        if branch is None and tree is not None:
419
415
            phrase = "branchless tree"
420
416
        else:
421
 
            if (tree is not None and tree.user_url !=
422
 
                branch.user_url):
 
417
            if (tree is not None and tree.bzrdir.root_transport.base !=
 
418
                branch.bzrdir.root_transport.base):
423
419
                independence = ''
424
420
                phrase = "Lightweight checkout"
425
421
            elif branch.get_bound_location() is not None:
444
440
    """
445
441
    candidates  = []
446
442
    if (branch is not None and tree is not None and
447
 
        branch.user_url != tree.user_url):
 
443
        branch.bzrdir.root_transport.base !=
 
444
        tree.bzrdir.root_transport.base):
448
445
        branch = None
449
446
        repository = None
450
447
    non_aliases = set(bzrdir.format_registry.keys())
475
472
        # do.
476
473
        candidates = new_candidates
477
474
    return ' or '.join(candidates)
478
 
 
479
 
 
480
 
class InfoHooks(_mod_hooks.Hooks):
481
 
    """Hooks for the info command."""
482
 
 
483
 
    def __init__(self):
484
 
        super(InfoHooks, self).__init__()
485
 
        self.create_hook(_mod_hooks.HookPoint('repository',
486
 
            "Invoked when displaying the statistics for a repository. "
487
 
            "repository is called with a statistics dictionary as returned "
488
 
            "by the repository and a file-like object to write to.", (1, 15), 
489
 
            None))
490
 
 
491
 
 
492
 
hooks = InfoHooks()