~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Aaron Bentley
  • Date: 2007-12-30 20:09:59 UTC
  • mto: This revision was merged to the branch mainline in revision 3164.
  • Revision ID: aaron.bentley@utoronto.ca-20071230200959-21ms4szwf591q3cv
Add NEWS entry

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
57
57
    See also bzr resolve.
58
58
    """
59
 
    takes_options = [Option('text', help='list text conflicts by pathname')]
 
59
    takes_options = [
 
60
            Option('text',
 
61
                   help='List paths of files with text conflicts.'),
 
62
        ]
60
63
 
61
64
    def run(self, text=False):
62
65
        from bzrlib.workingtree import WorkingTree
86
89
    """
87
90
    aliases = ['resolved']
88
91
    takes_args = ['file*']
89
 
    takes_options = [Option('all', help='Resolve all conflicts in this tree')]
 
92
    takes_options = [
 
93
            Option('all', help='Resolve all conflicts in this tree.'),
 
94
            ]
90
95
    def run(self, file_list=None, all=False):
91
96
        from bzrlib.workingtree import WorkingTree
92
97
        if all:
112
117
                resolve(tree, file_list)
113
118
 
114
119
 
115
 
def resolve(tree, paths=None, ignore_misses=False):
 
120
def resolve(tree, paths=None, ignore_misses=False, recursive=False):
 
121
    """Resolve some or all of the conflicts in a working tree.
 
122
 
 
123
    :param paths: If None, resolve all conflicts.  Otherwise, select only
 
124
        specified conflicts.
 
125
    :param recursive: If True, then elements of paths which are directories
 
126
        have all their children resolved, etc.  When invoked as part of
 
127
        recursive commands like revert, this should be True.  For commands
 
128
        or applications wishing finer-grained control, like the resolve
 
129
        command, this should be False.
 
130
    :ignore_misses: If False, warnings will be printed if the supplied paths
 
131
        do not have conflicts.
 
132
    """
116
133
    tree.lock_tree_write()
117
134
    try:
118
135
        tree_conflicts = tree.conflicts()
121
138
            selected_conflicts = tree_conflicts
122
139
        else:
123
140
            new_conflicts, selected_conflicts = \
124
 
                tree_conflicts.select_conflicts(tree, paths, ignore_misses)
 
141
                tree_conflicts.select_conflicts(tree, paths, ignore_misses,
 
142
                    recursive)
125
143
        try:
126
144
            tree.set_conflicts(new_conflicts)
127
145
        except errors.UnsupportedOperation:
228
246
                    if e.errno != errno.ENOENT:
229
247
                        raise
230
248
 
231
 
    def select_conflicts(self, tree, paths, ignore_misses=False):
 
249
    def select_conflicts(self, tree, paths, ignore_misses=False,
 
250
                         recurse=False):
232
251
        """Select the conflicts associated with paths in a tree.
233
252
        
234
253
        File-ids are also used for this.
253
272
                if cpath in path_set:
254
273
                    selected = True
255
274
                    selected_paths.add(cpath)
 
275
                if recurse:
 
276
                    if osutils.is_inside_any(path_set, cpath):
 
277
                        selected = True
 
278
                        selected_paths.add(cpath)
 
279
 
256
280
            for key in ('file_id', 'conflict_file_id'):
257
281
                cfile_id = getattr(conflict, key, None)
258
282
                if cfile_id is None: