~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Aaron Bentley
  • Date: 2009-03-11 06:44:59 UTC
  • Revision ID: aaron@aaronbentley.com-20090311064459-mez7p4g64e2xz7x9
Implement conflict-diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
514
514
        colordiff(color, check_style, *args, **kwargs)
515
515
 
516
516
 
 
517
class cmd_conflict_diff(BzrToolsCommand):
 
518
 
 
519
    """Compare a conflicted file against BASE."""
 
520
 
 
521
    encoding_type = 'exact'
 
522
    takes_args = ['file']
 
523
    takes_options = [
 
524
        RegistryOption.from_kwargs('new', 'blah', value_switches=True,
 
525
            enum_switch=False,
 
526
            other='Compare OTHER against common base.',
 
527
            this='Compare THIS against common base.')]
 
528
 
 
529
    def run(self, file, new='other'):
 
530
        from bzrlib.diff import internal_diff
 
531
        from bzrlib.plugins.bzrtools.colordiff import DiffWriter
 
532
        dw = DiffWriter(self.outf, check_style=False, color='auto')
 
533
        old_path = file + '.BASE'
 
534
        if new == 'other':
 
535
            new_path = file + '.OTHER'
 
536
        else:
 
537
            new_path = file + '.THIS'
 
538
        oldlines = open(old_path).readlines()
 
539
        newlines = open(new_path).readlines()
 
540
        internal_diff(old_path, oldlines, new_path, newlines, dw)
 
541
 
 
542
 
517
543
class cmd_rspush(BzrToolsCommand):
518
544
    """Upload this branch to another location using rsync.
519
545