开发者

VCS independent diff

Instead of running "svn diff", "hg diff" and so on .. can we开发者_JS百科 write a single command that calls svn/hg/git accordingly? Can the diff output be made pretty?

edit: command-line tools (not GUI) preferred.


There are also a number of "wrap all the common VCS commands into one utility" projects. pyvcs and UVC are two that come to mind. Maybe these would do what you want?


Typing "svn diff" or "hg diff" is no fun if you had to type it again just to page the output with less. Further, when it is likely that your text editor does syntax highlighting .. there is no reason why the diff output in the terminal should not also be highlighted with appropriate colors.

alt text http://img25.imageshack.us/img25/8597/colordiff.png

You will need colordiff which can be installed via apt or macports.

The following bash function will enable one to type just `dif' under the working directory of the VCS of your choice (no need to specify whether it is hg or svn).

function dif {
   if [ -d .hg ]; then
       VC='hg'
   elif [ -d .svn ]; then
       VC='svn'
   else
       echo "cannot find VC type"
       return 1
   fi
   $VC diff $1 | colordiff | less -R
}

It should be easy to add support for other VCS tools (git, cvs, etc..)

Additionally if you have UVC installed (as per Ryan Wilcox's answer), the above script can be simplified as:

function dif {
   uvc diff $1 | colordiff | less -R
}


Try Diffuse. It will figure out the appropriate version control system and display diffs with nice syntax highlighting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜