Print Color-Coded SVN Status
May 23rd, 09I’ve been having difficulty in reading SVN status, which tells you which files in a project have been modified, added, or having a conflict with other developer’s changes. Status code in front of each line alone doesn’t help me quickly identifying one status code from another so I wrote a script to color code the lines with different colors according to their statuses. If you’re having the same issue, feel free to use the code below
#!/usr/bin/python
"""
Author: Saophalkun Ponlu (http://phalkunz.com)
Contact: phalkunz@gmail.com
Date: May 23, 2009
"""
import sys, os, re
# add more status & color codes
colors = {
"M": "31", # red
"\?": "32", # green
"C": "30;41" # black on red
}
# build a paramter list
parameters = "";
for i in range(1, sys.argv.__len__()):
parameters += sys.argv[i] + " ";
status = os.popen('svn st ' + parameters);
for line in status:
passed = False
# remove newline character from the line
line = re.sub("\n", "", line)
for color in colors:
match = re.match(color+(" "*6), line)
if match:
os.popen("echo '\E[" + colors[color] + "m" + line + "\E[m'", 'w')
passed = True
if(passed):
continue
os.popen("echo \"" + line + "\"", 'w')
"""
Author: Saophalkun Ponlu (http://phalkunz.com)
Contact: phalkunz@gmail.com
Date: May 23, 2009
"""
import sys, os, re
# add more status & color codes
colors = {
"M": "31", # red
"\?": "32", # green
"C": "30;41" # black on red
}
# build a paramter list
parameters = "";
for i in range(1, sys.argv.__len__()):
parameters += sys.argv[i] + " ";
status = os.popen('svn st ' + parameters);
for line in status:
passed = False
# remove newline character from the line
line = re.sub("\n", "", line)
for color in colors:
match = re.match(color+(" "*6), line)
if match:
os.popen("echo '\E[" + colors[color] + "m" + line + "\E[m'", 'w')
passed = True
if(passed):
continue
os.popen("echo \"" + line + "\"", 'w')
This is a personal blog of Phalkunz. He currently works at
[...] Print Color-Coded SVN Status [...]
Pingback by Daily News About Tech : A few links about Tech - Friday, 22 May 2009 19:41 — May 23, 2009 @ 2:42 pm