/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Martin Pool
  • Date: 2006-10-06 02:04:17 UTC
  • mfrom: (1908.10.1 bench_usecases.merge2)
  • mto: This revision was merged to the branch mainline in revision 2068.
  • Revision ID: mbp@sourcefrog.net-20061006020417-4949ca86f4417a4d
merge additional fix from cfbolz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005 by Aaron Bentley
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
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
88
88
 
89
89
 
90
90
def resolve(tree, paths=None, ignore_misses=False):
91
 
    tree.lock_write()
 
91
    tree.lock_tree_write()
92
92
    try:
93
93
        tree_conflicts = tree.conflicts()
94
94
        if paths is None:
207
207
        """Select the conflicts associated with paths in a tree.
208
208
        
209
209
        File-ids are also used for this.
 
210
        :return: a pair of ConflictLists: (not_selected, selected)
210
211
        """
211
212
        path_set = set(paths)
212
213
        ids = {}
273
274
            return -1
274
275
        return cmp(self._cmp_list(), other._cmp_list())
275
276
 
 
277
    def __hash__(self):
 
278
        return hash((type(self), self.path, self.file_id))
 
279
 
276
280
    def __eq__(self, other):
277
281
        return self.__cmp__(other) == 0
278
282
 
292
296
        global ctype
293
297
        return ctype[type](**kwargs)
294
298
 
 
299
    @staticmethod
 
300
    def sort_key(conflict):
 
301
        if conflict.path is not None:
 
302
            return conflict.path, conflict.typestring
 
303
        elif getattr(conflict, "conflict_path", None) is not None:
 
304
            return conflict.conflict_path, conflict.typestring
 
305
        else:
 
306
            return None, conflict.typestring
 
307
 
295
308
 
296
309
class PathConflict(Conflict):
297
310
    """A conflict was encountered merging file paths"""
419
432
 
420
433
    typestring = 'unversioned parent'
421
434
 
422
 
    format = 'Conflict adding versioned files to %(path)s.  %(action)s.'
 
435
    format = 'Conflict because %(path)s is not versioned, but has versioned'\
 
436
             ' children.  %(action)s.'
423
437
 
424
438
 
425
439
class MissingParent(HandledConflict):
426
440
    """An attempt to add files to a directory that is not present.
427
 
    Typically, the result of a merge where one tree deleted the directory and
428
 
    the other added a file to it.
 
441
    Typically, the result of a merge where THIS deleted the directory and
 
442
    the OTHER added a file to it.
 
443
    See also: DeletingParent (same situation, reversed THIS and OTHER)
429
444
    """
430
445
 
431
446
    typestring = 'missing parent'
433
448
    format = 'Conflict adding files to %(path)s.  %(action)s.'
434
449
 
435
450
 
 
451
class DeletingParent(HandledConflict):
 
452
    """An attempt to add files to a directory that is not present.
 
453
    Typically, the result of a merge where one OTHER deleted the directory and
 
454
    the THIS added a file to it.
 
455
    """
 
456
 
 
457
    typestring = 'deleting parent'
 
458
 
 
459
    format = "Conflict: can't delete %(path)s because it is not empty.  "\
 
460
             "%(action)s."
 
461
 
436
462
 
437
463
ctype = {}
438
464
 
445
471
 
446
472
 
447
473
register_types(ContentsConflict, TextConflict, PathConflict, DuplicateID,
448
 
               DuplicateEntry, ParentLoop, UnversionedParent, MissingParent,)
 
474
               DuplicateEntry, ParentLoop, UnversionedParent, MissingParent,
 
475
               DeletingParent,)