Mercurial > diff-colorize
changeset 8:4bb2557d24cd
Now that these can come from the environment, they are variables. Lowercasing their names for this reason.
author | Peter Hosey |
---|---|
date | Mon, 11 Aug 2008 00:21:13 -0700 |
parents | c6337f653d9b |
children | cce6b860a98d |
files | diff-colorize.py |
diffstat | 1 files changed, 15 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/diff-colorize.py +++ b/diff-colorize.py @@ -4,12 +4,12 @@ import sys import os import fileinput -INDEX_COLOR = int(os.environ.get('DIFF_INDEX_COLOR', 32)) -OLD_MODE_COLOR = int(os.environ.get('DIFF_OLD_MODE_COLOR', 124)) -NEW_MODE_COLOR = int(os.environ.get('DIFF_NEW_MODE_COLOR', 28)) -REMOVED_COLOR = int(os.environ.get('DIFF_REMOVED_COLOR', 203)) -ADDED_COLOR = int(os.environ.get('DIFF_ADDED_COLOR', 2)) -HUNK_START_COLOR = int(os.environ.get('DIFF_HUNK_START_COLOR', 32)) +index_color = int(os.environ.get('DIFF_INDEX_COLOR', 32)) +old_mode_color = int(os.environ.get('DIFF_OLD_MODE_COLOR', 124)) +new_mode_color = int(os.environ.get('DIFF_NEW_MODE_COLOR', 28)) +removed_color = int(os.environ.get('DIFF_REMOVED_COLOR', 203)) +added_color = int(os.environ.get('DIFF_ADDED_COLOR', 2)) +hunk_start_color = int(os.environ.get('DIFF_HUNK_START_COLOR', 32)) RESET_FORMAT = '\033[0m' COLOR_FORMAT = '\033[38;5;%um' @@ -54,45 +54,45 @@ class OrderedDict(dict): # Theoretically, you could replace the key with some other string or leave it out entirely, if you wanted to, but I wouldn't recommend it. prefixes = OrderedDict() prefixes['---'] = ( - COLOR_FORMAT % (REMOVED_COLOR,) + COLOR_FORMAT % (removed_color,) + BEGIN_REVERSE_FORMAT + '---' + END_REVERSE_FORMAT ) prefixes['+++'] = ( - COLOR_FORMAT % (ADDED_COLOR,) + COLOR_FORMAT % (added_color,) + BEGIN_REVERSE_FORMAT + '+++' + END_REVERSE_FORMAT ) prefixes['-'] = ( - COLOR_FORMAT % (REMOVED_COLOR,) + COLOR_FORMAT % (removed_color,) + BEGIN_REVERSE_FORMAT + '-' + END_REVERSE_FORMAT ) prefixes['+'] = ( - COLOR_FORMAT % (ADDED_COLOR,) + COLOR_FORMAT % (added_color,) + BEGIN_REVERSE_FORMAT + '+' + END_REVERSE_FORMAT ) prefixes['old mode'] = ( # Git-style diffs only - COLOR_FORMAT % (OLD_MODE_COLOR,) + COLOR_FORMAT % (old_mode_color,) + BEGIN_REVERSE_FORMAT + 'old mode' + END_REVERSE_FORMAT ) prefixes['new mode'] = ( # Git-style diffs only - COLOR_FORMAT % (NEW_MODE_COLOR,) + COLOR_FORMAT % (new_mode_color,) + BEGIN_REVERSE_FORMAT + 'new mode' + END_REVERSE_FORMAT ) -prefixes['Index: '] = COLOR_FORMAT % (INDEX_COLOR,) + 'Index: ' -prefixes['diff --git '] = COLOR_FORMAT % (INDEX_COLOR,) + 'diff --git ' +prefixes['Index: '] = COLOR_FORMAT % (index_color,) + 'Index: ' +prefixes['diff --git '] = COLOR_FORMAT % (index_color,) + 'diff --git ' prefixes['@@'] = ( - COLOR_FORMAT % (HUNK_START_COLOR,) + COLOR_FORMAT % (hunk_start_color,) + BEGIN_REVERSE_FORMAT + '@@' )