~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Martin Pool
  • Date: 2007-04-04 06:17:31 UTC
  • mto: This revision was merged to the branch mainline in revision 2397.
  • Revision ID: mbp@sourcefrog.net-20070404061731-tt2xrzllqhbodn83
Contents of TODO file moved into bug tracker

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2007 Canonical Ltd
 
1
# Copyright (C) 2005 Aaron Bentley, 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
56
56
 
57
57
    See also bzr resolve.
58
58
    """
59
 
    takes_options = [
60
 
            Option('text',
61
 
                   help='List paths of files with text conflicts.'),
62
 
        ]
 
59
    takes_options = [Option('text', help='list text conflicts by pathname')]
63
60
 
64
61
    def run(self, text=False):
65
62
        from bzrlib.workingtree import WorkingTree
89
86
    """
90
87
    aliases = ['resolved']
91
88
    takes_args = ['file*']
92
 
    takes_options = [
93
 
            Option('all', help='Resolve all conflicts in this tree.'),
94
 
            ]
 
89
    takes_options = [Option('all', help='Resolve all conflicts in this tree')]
95
90
    def run(self, file_list=None, all=False):
96
91
        from bzrlib.workingtree import WorkingTree
97
92
        if all:
117
112
                resolve(tree, file_list)
118
113
 
119
114
 
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
 
    """
 
115
def resolve(tree, paths=None, ignore_misses=False):
133
116
    tree.lock_tree_write()
134
117
    try:
135
118
        tree_conflicts = tree.conflicts()
138
121
            selected_conflicts = tree_conflicts
139
122
        else:
140
123
            new_conflicts, selected_conflicts = \
141
 
                tree_conflicts.select_conflicts(tree, paths, ignore_misses,
142
 
                    recursive)
 
124
                tree_conflicts.select_conflicts(tree, paths, ignore_misses)
143
125
        try:
144
126
            tree.set_conflicts(new_conflicts)
145
127
        except errors.UnsupportedOperation:
246
228
                    if e.errno != errno.ENOENT:
247
229
                        raise
248
230
 
249
 
    def select_conflicts(self, tree, paths, ignore_misses=False,
250
 
                         recurse=False):
 
231
    def select_conflicts(self, tree, paths, ignore_misses=False):
251
232
        """Select the conflicts associated with paths in a tree.
252
233
        
253
234
        File-ids are also used for this.
272
253
                if cpath in path_set:
273
254
                    selected = True
274
255
                    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
 
 
280
256
            for key in ('file_id', 'conflict_file_id'):
281
257
                cfile_id = getattr(conflict, key, None)
282
258
                if cfile_id is None:
515
491
             "%(action)s."
516
492
 
517
493
 
518
 
class NonDirectoryParent(HandledConflict):
519
 
    """An attempt to add files to a directory that is not a director or
520
 
    an attempt to change the kind of a directory with files.
521
 
    """
522
 
 
523
 
    typestring = 'non-directory parent'
524
 
 
525
 
    format = "Conflict: %(path)s is not a directory, but has files in it."\
526
 
             "  %(action)s."
527
 
 
528
494
ctype = {}
529
495
 
530
496
 
537
503
 
538
504
register_types(ContentsConflict, TextConflict, PathConflict, DuplicateID,
539
505
               DuplicateEntry, ParentLoop, UnversionedParent, MissingParent,
540
 
               DeletingParent, NonDirectoryParent)
 
506
               DeletingParent,)