~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Robert Collins
  • Date: 2005-10-20 09:20:46 UTC
  • Revision ID: robertc@robertcollins.net-20051020092046-f41cd3e0c9896b98
Merge now has a retcode of 1 when conflicts occur. (Robert Collins)

'merge_flex' no longer calls conflict_handler.finalize(), instead that
is called by merge_inner. This is so that the conflict count can be 
retrieved (and potentially manipulated) before returning to the caller
of merge_inner. Likewise 'merge' now returns the conflict count to the
caller. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
321
321
            if not found_id:
322
322
                raise BzrCommandError("%s is not a source file in any"
323
323
                                      " tree." % fname)
324
 
    merge_inner(this_branch, other_tree, base_tree, tempdir=None, 
325
 
                ignore_zero=ignore_zero, backup_files=backup_files, 
326
 
                merge_type=merge_type, interesting_ids=interesting_ids,
327
 
                show_base=show_base)
 
324
    conflicts = merge_inner(this_branch, other_tree, base_tree, tempdir=None,
 
325
                            ignore_zero=ignore_zero,
 
326
                            backup_files=backup_files, 
 
327
                            merge_type=merge_type,
 
328
                            interesting_ids=interesting_ids,
 
329
                            show_base=show_base)
328
330
    if base_is_ancestor and other_rev_id is not None\
329
331
        and other_rev_id not in this_branch.revision_history():
330
332
        this_branch.add_pending_merge(other_rev_id)
 
333
    return conflicts
331
334
 
332
335
 
333
336
def set_interesting(inventory_a, inventory_b, interesting_ids):
352
355
    else:
353
356
        _tempdir = tempdir
354
357
    try:
355
 
        _merge_inner(this_branch, other_tree, base_tree, _tempdir,
356
 
                     ignore_zero, merge_type, backup_files, interesting_ids,
357
 
                     show_base=show_base)
 
358
        return _merge_inner(this_branch, other_tree, base_tree, _tempdir,
 
359
                            ignore_zero, merge_type, backup_files,
 
360
                            interesting_ids,
 
361
                            show_base=show_base)
358
362
    finally:
359
363
        if tempdir is None:
360
364
            shutil.rmtree(_tempdir)
377
381
    def get_inventory(tree):
378
382
        return tree.inventory
379
383
 
 
384
    conflict_handler = MergeConflictHandler(this_tree, base_tree, other_tree,
 
385
                                            ignore_zero=ignore_zero)
380
386
    inv_changes = merge_flex(this_tree, base_tree, other_tree,
381
387
                             generate_changeset, get_inventory,
382
 
                             MergeConflictHandler(this_tree, base_tree,
383
 
                             other_tree, ignore_zero=ignore_zero),
 
388
                             conflict_handler,
384
389
                             merge_factory=merge_factory, 
385
390
                             interesting_ids=interesting_ids)
386
391
 
397
402
        this_branch.set_inventory(regen_inventory(this_branch, 
398
403
                                                  this_tree.basedir,
399
404
                                                  adjust_ids))
 
405
    conflicts = conflict_handler.conflicts
 
406
    conflict_handler.finalize()
 
407
    return conflicts
400
408
 
401
409
 
402
410
def regen_inventory(this_branch, root, new_entries):