~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Aaron Bentley
  • Date: 2009-04-10 20:07:41 UTC
  • Revision ID: aaron@aaronbentley.com-20090410200741-qg98vn5l50mcwzd1
Get conflict-diff under test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
530
530
            this='Compare THIS against common base.')]
531
531
 
532
532
    def run(self, file, direction='other'):
533
 
        from bzrlib.diff import internal_diff
534
533
        from bzrlib.plugins.bzrtools.colordiff import DiffWriter
 
534
        from conflict_diff import conflict_diff
535
535
        dw = DiffWriter(self.outf, check_style=False, color='auto')
536
 
        old_path = file + '.BASE'
537
 
        new_path_extension = {
538
 
            'other': '.OTHER',
539
 
            'this': '.THIS'}[direction]
540
 
        new_path = file + new_path_extension
541
 
        try:
542
 
            oldlines = open(old_path).readlines()
543
 
        except IOError, e:
544
 
            if e.errno != errno.ENOENT:
545
 
                raise
546
 
            tree, path = WorkingTree.open_containing(file)
547
 
            tree.lock_read()
548
 
            try:
549
 
                file_id = tree.path2id(path)
550
 
                graph = tree.branch.repository.get_graph()
551
 
                lca = graph.find_unique_lca(*tree.get_parent_ids())
552
 
                oldtree = tree.branch.repository.revision_tree(lca)
553
 
                oldlines = oldtree.get_file_lines(file_id)
554
 
            finally:
555
 
                tree.unlock()
556
 
        newlines = open(new_path).readlines()
557
 
        internal_diff(old_path, oldlines, new_path, newlines, dw)
 
536
        conflict_diff(dw, file, direction)
558
537
 
559
538
 
560
539
class cmd_rspush(BzrToolsCommand):