diff diff-colorize.py @ 5:fa7cd4c2716b

Added prefixes “old mode” and “new mode”, found in Git-style diffs, along with new color constants for them. We treat these the same way we treat “---” and “+++”.
author Peter Hosey
date Sun, 10 Aug 2008 23:50:06 -0700
parents b8b2d1931a9e
children d58b4e2e12d4
line wrap: on
line diff
--- a/diff-colorize.py
+++ b/diff-colorize.py
@@ -3,6 +3,8 @@
 import os
 
 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))
@@ -58,6 +60,18 @@ prefixes['+'] = (
 	+ '+'
 	+ END_REVERSE_FORMAT
 )
+prefixes['old mode'] = ( # Git-style diffs only
+	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,)
+	+ 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['@@'] = (