~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Vincent Ladeuil
  • Date: 2016-01-21 17:48:07 UTC
  • mto: This revision was merged to the branch mainline in revision 6613.
  • Revision ID: v.ladeuil+lp@free.fr-20160121174807-g4ybpaij9ln5wj6a
Make all transport put_bytes() raises TypeError when given unicode strings rather than bytes.

There was a mix of AssertionError or UnicodeEncodeError.

Also deleted test_put_file_unicode() which was bogus, files contain bytes not unicode strings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# TODO: 'bzr resolve' should accept a directory name and work from that
18
18
# point down
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import os
21
23
 
22
24
from bzrlib.lazy_import import lazy_import
32
34
    transform,
33
35
    workingtree,
34
36
    )
 
37
from bzrlib.i18n import gettext, ngettext
35
38
""")
36
39
from bzrlib import (
37
40
    commands,
49
52
    Merge will do its best to combine the changes in two branches, but there
50
53
    are some kinds of problems only a human can fix.  When it encounters those,
51
54
    it will mark a conflict.  A conflict means that you need to fix something,
52
 
    before you should commit.
 
55
    before you can commit.
53
56
 
54
57
    Conflicts normally are listed as short, human-readable messages.  If --text
55
58
    is supplied, the pathnames of files with text conflicts are listed,
79
82
 
80
83
 
81
84
resolve_action_registry.register(
82
 
    'done', 'done', 'Marks the conflict as resolved' )
 
85
    'done', 'done', 'Marks the conflict as resolved.')
83
86
resolve_action_registry.register(
84
87
    'take-this', 'take_this',
85
 
    'Resolve the conflict preserving the version in the working tree' )
 
88
    'Resolve the conflict preserving the version in the working tree.')
86
89
resolve_action_registry.register(
87
90
    'take-other', 'take_other',
88
 
    'Resolve the conflict taking the merged version into account' )
 
91
    'Resolve the conflict taking the merged version into account.')
89
92
resolve_action_registry.default_key = 'done'
90
93
 
91
94
class ResolveActionOption(option.RegistryOption):
103
106
    Merge will do its best to combine the changes in two branches, but there
104
107
    are some kinds of problems only a human can fix.  When it encounters those,
105
108
    it will mark a conflict.  A conflict means that you need to fix something,
106
 
    before you should commit.
 
109
    before you can commit.
107
110
 
108
111
    Once you have fixed a problem, use "bzr resolve" to automatically mark
109
112
    text conflicts as fixed, "bzr resolve FILE" to mark a specific conflict as
120
123
    def run(self, file_list=None, all=False, action=None, directory=None):
121
124
        if all:
122
125
            if file_list:
123
 
                raise errors.BzrCommandError("If --all is specified,"
124
 
                                             " no FILE may be provided")
 
126
                raise errors.BzrCommandError(gettext("If --all is specified,"
 
127
                                             " no FILE may be provided"))
125
128
            if directory is None:
126
129
                directory = u'.'
127
130
            tree = workingtree.WorkingTree.open_containing(directory)[0]
145
148
            if file_list is None:
146
149
                un_resolved, resolved = tree.auto_resolve()
147
150
                if len(un_resolved) > 0:
148
 
                    trace.note('%d conflict(s) auto-resolved.', len(resolved))
149
 
                    trace.note('Remaining conflicts:')
 
151
                    trace.note(ngettext('%d conflict auto-resolved.',
 
152
                        '%d conflicts auto-resolved.', len(resolved)),
 
153
                        len(resolved))
 
154
                    trace.note(gettext('Remaining conflicts:'))
150
155
                    for conflict in un_resolved:
151
156
                        trace.note(unicode(conflict))
152
157
                    return 1
153
158
                else:
154
 
                    trace.note('All conflicts resolved.')
 
159
                    trace.note(gettext('All conflicts resolved.'))
155
160
                    return 0
156
161
            else:
157
162
                # FIXME: This can never occur but the block above needs some
160
165
                pass
161
166
        else:
162
167
            before, after = resolve(tree, file_list, action=action)
163
 
            trace.note('%d conflict(s) resolved, %d remaining'
164
 
                       % (before - after, after))
 
168
            trace.note(ngettext('{0} conflict resolved, {1} remaining',
 
169
                                '{0} conflicts resolved, {1} remaining',
 
170
                                before-after).format(before - after, after))
165
171
 
166
172
 
167
173
def resolve(tree, paths=None, ignore_misses=False, recursive=False,