~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to colordiff.py

  • Committer: Aaron Bentley
  • Date: 2008-11-23 20:15:03 UTC
  • mfrom: (680.1.3 colordiff_when_tty)
  • Revision ID: aaron@aaronbentley.com-20081123201503-rov0dqgwl0mjz9hj
Merge support for disabling colour output in cdiff

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
        self._old_lines, self._new_lines = ([], [])
180
180
 
181
181
 
182
 
def colordiff(check_style, *args, **kwargs):
 
182
def colordiff(color, check_style, *args, **kwargs):
 
183
    from terminal import has_ansi_colors
 
184
    if 'never' == color or ('auto' == color and not has_ansi_colors()):
 
185
        get_cmd_object('diff').run(*args, **kwargs)
 
186
        return
183
187
    real_stdout = sys.stdout
184
188
    dw = DiffWriter(real_stdout, check_style)
185
189
    sys.stdout = dw