~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__.

This is used to replace various ad hoc implementations of the same logic,
notably the version used in registry's _LazyObjectGetter which had a bug when
getting a module without also getting a member.  And of course, this new
function has unit tests, unlike the replaced code.

This also adds a KnownHooksRegistry subclass to provide a more natural home for
some other logic.

I'm not thrilled about the name of the new module or the new functions, but it's
hard to think of good names for such generic functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import errno
25
25
 
26
26
from bzrlib import (
27
 
    builtins,
28
27
    cleanup,
29
28
    commands,
30
29
    errors,
59
58
    Use bzr resolve when you have fixed a problem.
60
59
    """
61
60
    takes_options = [
 
61
            'directory',
62
62
            option.Option('text',
63
63
                          help='List paths of files with text conflicts.'),
64
64
        ]
65
65
    _see_also = ['resolve', 'conflict-types']
66
66
 
67
 
    def run(self, text=False):
68
 
        wt = workingtree.WorkingTree.open_containing(u'.')[0]
 
67
    def run(self, text=False, directory=u'.'):
 
68
        wt = workingtree.WorkingTree.open_containing(directory)[0]
69
69
        for conflict in wt.conflicts():
70
70
            if text:
71
71
                if conflict.typestring != 'text conflict':
112
112
    aliases = ['resolved']
113
113
    takes_args = ['file*']
114
114
    takes_options = [
 
115
            'directory',
115
116
            option.Option('all', help='Resolve all conflicts in this tree.'),
116
117
            ResolveActionOption(),
117
118
            ]
118
119
    _see_also = ['conflicts']
119
 
    def run(self, file_list=None, all=False, action=None):
 
120
    def run(self, file_list=None, all=False, action=None, directory=u'.'):
120
121
        if all:
121
122
            if file_list:
122
123
                raise errors.BzrCommandError("If --all is specified,"
123
124
                                             " no FILE may be provided")
124
 
            tree = workingtree.WorkingTree.open_containing('.')[0]
 
125
            tree = workingtree.WorkingTree.open_containing(directory)[0]
125
126
            if action is None:
126
127
                action = 'done'
127
128
        else:
128
 
            tree, file_list = builtins.tree_files(file_list)
 
129
            tree, file_list = workingtree.WorkingTree.open_containing_paths(
 
130
                file_list)
129
131
            if file_list is None:
130
132
                if action is None:
131
133
                    # FIXME: There is a special case here related to the option