EDIT: Here is the GitHub updated version of this snippet, stable.
Here is a part of Bash code (I put it in .bashrc file) which works:
function svn {
command svn "$@" | awk '
BEGIN {
cpt_c=0;
}
{
if ($1=="C") {
cpt_c=cpt_c+1;
print "\033[31m" $0 "\033[00m"; # Conflicts are displayed in red
}
else if ($1=="A") {
print "\033[32m" $0 "\033[00m"; # Add in green
}
else if ($1=="?") {
print "\033[36m" $0 "\033[00m"; # New in cyan
}
else if ($1=="D") {
print "\033[35m" $0 "\033[00m"; # Delete in magenta
}
else {
print $0; # No color, just print the line
}
}
END {
print cpt_c, " conflicts are found.";
}';
}
This part of code do exactly what I want. svn functions (status, update, etc.) are printed with colors. For internally needs, I don't want to install such things as colorsvn or svn-color.
Here is an example of the code above:
And again, that is perfectly what I want. The problem happens when a conflict is found (for instance when I do an update): indeed, when a file is conflicted, svn is handed over to the user, to let him type a few letters (see below)
# svn update
Conflict discovered in 'test.txt'.
Select: (p) postpone, (df) diff-full, (e) edit,
(mc) mine-conflict, (tc) theirs-conflict,
(s) show all options:
Is there a way to awk to let the user type something (for instance e, which open in VIm the conflicted file), do something (for instance delete some lines after type e, then save&quit), and type another letter to confirm solving conflict, then finally display the next step of svn update (others files, etc)?
In other words, I want to "pause" the script which display colors to let user interact with svn, then svn update go on. I think it 'll be very useful for future to know how can let awk pause the caller script, then resume!
Did you try to run svn update --accept postpone
so that svn
doesn't prompt for conflicts?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With