/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/bundle/commands.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-05 14:26:58 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120105142658-vek3v6pzlxb751s2
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. 

@only_raises is evil and gave a hard time since any exception during
save_changes() was swallowed.

Possible improvements: 

- add some needs_write_lock decorators to crucial
  methods (_set_config_location ?) but keep locking the branch at higher levels

- decorate branch.unlock to call stack.save if last_lock() it True
  outside of @only_raises scope (evil decorator)

- add @needs_write_lock to stack.set and stack.remove (will probably get
  rid of most testing issues) we probably need a specialized decorator
  that can relay to the store and from there to the branch or whatever is
  needed. This will also helps bzr config to get it right. The
  get_mutable_section trick should not be needed anymore either.

- decorate branch.unlock to call stack.save if last_lock() it True outside
  of @only_raises scope (evil decorator)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
16
17
"""\
17
18
This is an attempt to take the internal delta object, and represent
18
19
it as a single-file text-only changeset.
20
21
and for applying a changeset.
21
22
"""
22
23
 
23
 
import sys
 
24
from __future__ import absolute_import
 
25
 
24
26
from cStringIO import StringIO
25
27
 
26
28
from bzrlib.lazy_import import lazy_import
33
35
    urlutils,
34
36
    transport,
35
37
    )
 
38
from bzrlib.i18n import gettext
36
39
""")
37
40
 
38
41
from bzrlib.commands import Command
39
 
from bzrlib.option import Option
40
 
from bzrlib.trace import note
41
42
 
42
43
 
43
44
class cmd_bundle_info(Command):
59
60
            bundle_info = read_bundle(bundle_file)
60
61
        else:
61
62
            if verbose:
62
 
                raise errors.BzrCommandError('--verbose requires a merge'
63
 
                    ' directive')
 
63
                raise errors.BzrCommandError(gettext(
 
64
                            '--verbose requires a merge directive'))
64
65
        reader_method = getattr(bundle_info, 'get_bundle_reader', None)
65
66
        if reader_method is None:
66
 
            raise errors.BzrCommandError('Bundle format not supported')
 
67
            raise errors.BzrCommandError(gettext('Bundle format not supported'))
67
68
 
68
69
        by_kind = {}
69
70
        file_ids = set()
73
74
                (bytes, parents, repo_kind, revision_id, file_id))
74
75
            if file_id is not None:
75
76
                file_ids.add(file_id)
76
 
        self.outf.write('Records\n')
 
77
        self.outf.write(gettext('Records\n'))
77
78
        for kind, records in sorted(by_kind.iteritems()):
78
79
            multiparent = sum(1 for b, m, k, r, f in records if
79
80
                              len(m.get('parents', [])) > 1)
80
 
            self.outf.write('%s: %d (%d multiparent)\n' % \
81
 
                (kind, len(records), multiparent))
82
 
        self.outf.write('unique files: %d\n' % len(file_ids))
 
81
            self.outf.write(gettext('{0}: {1} ({2} multiparent)\n').format(
 
82
                kind, len(records), multiparent))
 
83
        self.outf.write(gettext('unique files: %d\n') % len(file_ids))
83
84
        self.outf.write('\n')
84
85
        nicks = set()
85
86
        committers = set()
88
89
                nicks.add(revision.properties['branch-nick'])
89
90
            committers.add(revision.committer)
90
91
 
91
 
        self.outf.write('Revisions\n')
92
 
        self.outf.write(('nicks: %s\n'
 
92
        self.outf.write(gettext('Revisions\n'))
 
93
        self.outf.write((gettext('nicks: %s\n')
93
94
            % ', '.join(sorted(nicks))).encode(term_encoding, 'replace'))
94
 
        self.outf.write(('committers: \n%s\n' %
 
95
        self.outf.write((gettext('committers: \n%s\n') %
95
96
        '\n'.join(sorted(committers)).encode(term_encoding, 'replace')))
96
97
        if verbose:
97
98
            self.outf.write('\n')
99
100
            line = bundle_file.readline()
100
101
            line = bundle_file.readline()
101
102
            content = bundle_file.read().decode('bz2')
102
 
            self.outf.write("Decoded contents\n")
 
103
            self.outf.write(gettext("Decoded contents\n"))
103
104
            self.outf.write(content)
104
105
            self.outf.write('\n')