DiffPlug can be automatated using the dp
command line tool. The dp
included in DiffPlug 2 is not backward-compatible with DiffPlug 1.
Installation
Windows
dp.bat
lives in the DiffPlug installation directory. All you have to do is add this directory to your system path.
If it's not working as expected:
- open new cmd prompt
- run
where dp
- it should print the directory you just added
- if it doesn't, there is another folder earlier in the path with
dp
Mac
The dp
executable lives in the DiffPlug.app/Contents/Resources/dp
. To make it easily available everywhere, just run
sudo ln -s /Applications/DiffPlug.app/Contents/Resources/dp /usr/local/bin/dp
If it's not working as expected:
- open a new terminal
- run
which dp
- it should print
/usr/local/bin/dp
- then
ls -l /usr/local/bin/dp
- it should print
/Applications/DiffPlug.app/Contents/Resources/dp
It is fine to put DiffPlug.app
somewhere else besides /Applications
, just change the instructions appropriately.
Linux
The dp
executable lives in the <DiffPlug install directory>/dp
. To make it easily available everywhere, just run
sudo ln -s <DiffPlug install directory>/dp /usr/local/bin/dp
If it's not working as expected:
- open a new terminal
- run
which dp
- it should print
/usr/local/bin/dp
- then
ls -l /usr/local/bin/dp
- it should print
<DiffPlug install directory>/dp
General usage
dp
will connect to whichever instance of DiffPlug 2 was launched most recently.
To see what commands are available, simply run dp
at a console.
cmd> dp
You must specify a command.
usage: dp <command> [args ...]
'dp help <command>' for more info. Available commands:
add Adds the given paths to the palette
cat Dumps an entity's binary content to standard output
slurp Slurps standard input into the given entity
ext Integration with external vcs clients (open, diff, and merge)
To get help for a particular command, type dp help <command>
cmd> dp help ext
Integration with external vcs clients (open, diff, and merge)
usage: dp ext -before FILE [-after FILE] [-ours FILE] [-theirs FILE] [-result FILE]
-before FILE : base file
-after FILE : 2-way diff - file after change
-ours FILE : 3-way diff - file after our changes
-theirs FILE : 3-way diff - file after their changes
-result FILE : editiable version of file, converts diff to merge
<Further docs>
Integrating with external tools using "dp ext"
One of dp ext
's features is that the dp
will remain running so long as the files it referenced are still open in DiffPlug. You can have multiple calls to dp ext
, and each will close at the appropriate time when you have stopped using those temporary files in DiffPlug.
This is especially important for comparing folders, and using DiffPlug as a conflict resolution tool.
Here are some quick integrations for common version control tools:
Tool | Cmd | More info |
---|---|---|
git difftool | dp ext -before "$LOCAL" -after "$REMOTE" -result "$MERGED" | docs |
git mergetool | dp ext -before "$BASE" -ours "$LOCAL" -theirs "$REMOTE" -result "$MERGED" | docs |
mercurial | dp ext -before $base -ours $local -theirs $other -result $output | docs |
TortoiseSVN diff | dp ext -before %base -beforeName %bname -after %mine -afterName %yname | docs |
TortoiseSVN merge | dp ext -before %base -beforeName %bname -ours %mine -oursName %yname -theirs %theirs -theirsName %tname -result %merged | (see above) |
TortoiseHg
Set your ~/mercurial.ini
to be similar to the following:
[tortoisehg]
vdiff=diffplug2
[merge-tools]
diffplug2.executable = PATH_TO_EXTRACTED_FOLDER\dp.bat
diffplug2.args = ext -flavor tortoiseHg -before $base -ours $local -theirs $other -result $output
diffplug2.diffargs= ext -flavor tortoiseHg -before $parent -after $child -beforeName '$plabel1' -afterName '$clabel'
diffplug2.diff3args= ext -flavor tortoiseHg -before $parent1 -beforeName '$plabel1' -ours $child -oursName '$clabel' -theirs $parent2 -theirsName '$plabel2'
diffplug2.binary = true
diffplug2.symlink = false
diffplug2.gui = true
diffplug2.priority = 1
diffplug2.dirdiff=True
[merge-patterns]
**.slx = diffplug2
**.mdl = diffplug2
[ui]
diff = diffplug2
merge = diffplug2
Atlassian SourceTree
- From the menu bar, select
Tools -> Options
- In the
Diff
tab, setExternal Diff / Merge
to:- Diff Arguments:
ext -before \"$REMOTE\" -after \"$LOCAL\"
- Merge Arguments:
ext -before \"$BASE\" -ours \"$LOCAL\" -theirs \"$REMOTE\" -result \"$MERGED\"
- Diff Arguments:
- Now, whenever you click a changed file, you can click the gear drop down and select
External Diff
to open the diff in DiffPlug. - NOTE: SourceTree will only allow one "External Diff" to happen at a time. You have to close the previous diff in DiffPlug before SourceTree will initiate a new diff.