简体   繁体   中英

is there a way to pipe the git or Mercurial diff output to a GUI Diff tool?

the diff result in text might be hard to get used to at first. Is there a way to pipe that output to a visual diff tool, such as something like

$ hg diff --visual code.rb

or

$ hg diff code.rb | sometool

so that the result can be viewed visually?

git has a "difftool" subcommand that can be used to invoke an external diff viewer, eg kdiff3.

This is separate to the "external diff driver" than can be used for example if you prefer context diffs, as some people do .

Search the web for info on hg vdiff . I've used it and it works fine.

Seems like the following will work:

in your ~/.hgrc (UNIX / Mac) or c:\\users[your username]\\mercurial.ini, add

[extensions]
extdiff=

[extdiff]
cmd.vdiff = opendiff
cmd.kdiff = kdiff3

and now you can do

hg vdiff filename
hg kdiff filename

the opendiff or kdiff3 must be tools already installed on your machine, or you can use whatever visual diff tool that you have.

in fact, you can add

cmd.echo = echo

and see that echo will echo 2 filenames out when you do a

hg echo filename
hg echo -r -2 filename         <-- you will see different filenames if that revision exists

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM