~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2006-04-19 01:23:36 UTC
  • mfrom: (1669 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1673.
  • Revision ID: aaron.bentley@utoronto.ca-20060419012336-a74d3d2ea435d15f
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
from bzrlib.trace import mutter, warning, note
48
48
from bzrlib.transform import (TreeTransform, resolve_conflicts, cook_conflicts,
49
49
                              FinalPaths, create_by_entry, unique_add)
 
50
from bzrlib.versionedfile import WeaveMerge
50
51
import bzrlib.ui
51
52
 
52
53
# TODO: Report back as changes are merged in
246
247
        if self.merge_type.supports_reprocess:
247
248
            kwargs['reprocess'] = self.reprocess
248
249
        elif self.reprocess:
249
 
            raise BzrError("Reprocess is not supported for this merge"
250
 
                                  " type. %s" % merge_type)
 
250
            raise BzrError("Conflict reduction is not supported for merge"
 
251
                                  " type %s." % self.merge_type)
251
252
        if self.merge_type.supports_show_base:
252
253
            kwargs['show_base'] = self.show_base
253
254
        elif self.show_base:
284
285
        for file_id in old_entries:
285
286
            entry = old_entries[file_id]
286
287
            path = id2path(file_id)
 
288
            if file_id in self.base_tree.inventory:
 
289
                executable = getattr(self.base_tree.inventory[file_id], 'executable', False)
 
290
            else:
 
291
                executable = getattr(entry, 'executable', False)
287
292
            new_inventory[file_id] = (path, file_id, entry.parent_id, 
288
 
                                      entry.kind)
 
293
                                      entry.kind, executable)
 
294
                                      
289
295
            by_path[path] = file_id
290
296
        
291
297
        deletions = 0
308
314
                parent = by_path[os.path.dirname(path)]
309
315
            abspath = pathjoin(self.this_tree.basedir, path)
310
316
            kind = bzrlib.osutils.file_kind(abspath)
311
 
            new_inventory[file_id] = (path, file_id, parent, kind)
 
317
            if file_id in self.base_tree.inventory:
 
318
                executable = getattr(self.base_tree.inventory[file_id], 'executable', False)
 
319
            else:
 
320
                executable = False
 
321
            new_inventory[file_id] = (path, file_id, parent, kind, executable)
312
322
            by_path[path] = file_id 
313
323
 
314
324
        # Get a list in insertion order
765
775
 
766
776
class WeaveMerger(Merge3Merger):
767
777
    """Three-way tree merger, text weave merger."""
768
 
    supports_reprocess = False
 
778
    supports_reprocess = True
769
779
    supports_show_base = False
770
780
 
771
781
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
772
 
                 interesting_ids=None, pb=DummyProgress(), pp=None):
 
782
                 interesting_ids=None, pb=DummyProgress(), pp=None,
 
783
                 reprocess=False):
773
784
        self.this_revision_tree = self._get_revision_tree(this_tree)
774
785
        self.other_revision_tree = self._get_revision_tree(other_tree)
775
786
        super(WeaveMerger, self).__init__(working_tree, this_tree, 
776
787
                                          base_tree, other_tree, 
777
788
                                          interesting_ids=interesting_ids, 
778
 
                                          pb=pb, pp=pp)
 
789
                                          pb=pb, pp=pp, reprocess=reprocess)
779
790
 
780
791
    def _get_revision_tree(self, tree):
781
792
        """Return a revision tree releated to this tree.
805
816
        this_revision_id = self.this_revision_tree.inventory[file_id].revision
806
817
        other_revision_id = \
807
818
            self.other_revision_tree.inventory[file_id].revision
808
 
        plan =  weave.plan_merge(this_revision_id, other_revision_id)
809
 
        return weave.weave_merge(plan, '<<<<<<< TREE\n', 
810
 
                                       '>>>>>>> MERGE-SOURCE\n')
 
819
        wm = WeaveMerge(weave, this_revision_id, other_revision_id, 
 
820
                        '<<<<<<< TREE\n', '>>>>>>> MERGE-SOURCE\n')
 
821
        return wm.merge_lines(self.reprocess)
811
822
 
812
823
    def text_merge(self, file_id, trans_id):
813
824
        """Perform a (weave) text merge for a given file and file-id.
815
826
        and a conflict will be noted.
816
827
        """
817
828
        self._check_file(file_id)
818
 
        lines = list(self._merged_lines(file_id))
819
 
        conflicts = '<<<<<<< TREE\n' in lines
 
829
        lines, conflicts = self._merged_lines(file_id)
 
830
        lines = list(lines)
820
831
        # Note we're checking whether the OUTPUT is binary in this case, 
821
832
        # because we don't want to get into weave merge guts.
822
833
        check_text_lines(lines)