~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

Implement conflicts.ResolveActionOption.

* bzrlib/tests/test_conflicts.py:
(TestResolveActionOption): Test the values for action option.

* bzrlib/conflicts.py:
(resolve_action_registry, ResolveActionOption): Define all
conflict resolution actions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    workingtree,
34
34
    )
35
35
""")
36
 
from bzrlib.option import Option
 
36
from bzrlib import (
 
37
    option,
 
38
    registry,
 
39
    )
37
40
 
38
41
 
39
42
CONFLICT_SUFFIXES = ('.THIS', '.BASE', '.OTHER')
54
57
    Use bzr resolve when you have fixed a problem.
55
58
    """
56
59
    takes_options = [
57
 
            Option('text',
58
 
                   help='List paths of files with text conflicts.'),
 
60
            option.Option('text',
 
61
                          help='List paths of files with text conflicts.'),
59
62
        ]
60
63
    _see_also = ['resolve']
61
64
 
70
73
                self.outf.write(str(conflict) + '\n')
71
74
 
72
75
 
 
76
resolve_action_registry = registry.Registry()
 
77
 
 
78
 
 
79
resolve_action_registry.register(
 
80
    'done', 'done', 'Marks the conflict as resolved' )
 
81
resolve_action_registry.register(
 
82
    'keep-mine', 'keep_mine',
 
83
    'Resolve the conflict preserving the version in the working tree' )
 
84
resolve_action_registry.register(
 
85
    'take-theirs', 'take_theirs',
 
86
    'Resolve the conflict taking the merged version into account' )
 
87
resolve_action_registry.default_key = 'done'
 
88
 
 
89
class ResolveActionOption(option.RegistryOption):
 
90
 
 
91
    def __init__(self):
 
92
        super(ResolveActionOption, self).__init__(
 
93
            'action', 'How to resolve the conflict.',
 
94
            value_switches=True,
 
95
            registry=resolve_action_registry)
 
96
 
 
97
 
73
98
class cmd_resolve(commands.Command):
74
99
    """Mark a conflict as resolved.
75
100
 
85
110
    aliases = ['resolved']
86
111
    takes_args = ['file*']
87
112
    takes_options = [
88
 
            Option('all', help='Resolve all conflicts in this tree.'),
89
 
            Option('interactive', help='Dialog-based resolution'),
 
113
            option.Option('all', help='Resolve all conflicts in this tree.'),
 
114
            option.Option('interactive', help='Dialog-based resolution'),
90
115
            ]
91
116
    _see_also = ['conflicts']
92
117
    def run(self, file_list=None, all=False, interactive=False):