SCM Integration Scripts

From ChangesWiki

Jump to: navigation, search

Contents

[edit] SCM Integration

[edit] Summary

Most SCM integration is accomplished by using integration scripts. These scripts generally leverage the power of the chdiff utility by using it to initiate a diff between two files in Changes.

Note: you can install the chdiff utility by using the Install Terminal Utility... menu item from the Changes menu in the application. It will be symlinked into the /usr/bin directory.

[edit] Subversion Integration

Download the file svndiffshim.py to your ~/bin directory. When you want to run a diff, use the following command line:

svn diff --diff-cmd ~/bin/svndiffshim.py

Alternatively, you can set the diff-cmd options in your Subversion config file: ~/.subversion/config, in the helpers section:

diff-cmd = /Users/YOUR_LOGIN/bin/svndiffshim.py

You might need to set permissions to allow for the script to execute:

chmod 755 ~/bin/svndiffshim.py

[edit] SVK Integration

First, put the following in ~/bin/svk-chdiff:

#!/usr/bin/ruby
working = "#{ARGV[1]}".sub!(/\t\(.*\)/, '')
head = "#{ARGV[2]}.svk"
system "cp #{ARGV[2]} #{head}"
system "chdiff #{head} #{working}"

Next, set the SVKDIFF environment variable to ~/bin/svk-chdiff:

export SVKDIFF=~/bin/svk-chdiff  # For sh-based shells
setenv SVKDIFF ~/bin/svk-chdiff  # For csh-based shells

Finally, run the diff using svk diff.

[edit] CVS Integration

Add the following script to your ~/bin directory (name it cvsdiff, for example). To run a diff, use the following command line: bamboo sheetsmake money online internet tips work from home

cvsdiff filename

#!/bin/sh
# Adapted from http://www.macosxhints.com/article.php?story=20040316115029198
SCRIPTNAME="${0##*/}" 
OLDFILE=/tmp/"${1##*/}"
NEWFILE="$1"
if [ $# -eq 1 ]
then
   cvs update -p "$NEWFILE" > "$OLDFILE"
elif [ $# -eq 2 ]
then
   cvs update -p -r "$2" "$NEWFILE"  > "$OLDFILE"
else
   echo "usage: $SCRIPTNAME <file> [rev]"
   exit 1
fi
chdiff "$OLDFILE" "$NEWFILE"

[edit] P4 Integration

Perforce integration is very easy, for basic operation just set the environment variable $P4DIFF to /usr/bin/chdiff. To run the diff just run:

p4 diff filename.

It is recommended to set the $P4DIFF variable to '/usr/bin/chdiff --wait' so that operations using Perforce's triple dot notation (...) will work in sequence rather than diffing all files at once. All that is needed to advance to the next file is to close the Changes.app window that was most recently opened by p4 diff.

[edit] Mercurial (Hg) Integration

1. Add the following to your ~/.hgrc file:

[extensions] 
extdiff =

[extdiff]
cmd.chdiff =
opts.chdiff = --wait

2. To perform a diff, simply run:

hg chdiff

To use Changes for merging, create a file with the following contents and make it executable:

#!/bin/sh
chdiff --wait $3 $1

Then, set the HGMERGE environment variable to the full path to the above file. When merging is needed, Mercurial will call this script with three arguments; your local revision, the base revision and the "incoming" revision. As Changes does not yet provide three-way merging, the base revision is dropped.


With Mercurial 1.0 there's a simpler method for the merging part. On your ~/.hgrc file add:

[merge-tools]
changes.executable = chdiff
changes.args = --wait $local $other

And that's all, you don't need the script and the environment variable.

[edit] Git Integration

The basic method of having git use an external program is to set the GIT_EXTERNAL_DIFF environment variable. When set git will pass on seven command line options that chdiff does not yet understand. The two options it needs must be pulled out and passed on. This simple shell script will do that:

#!/bin/sh
[ $# -eq 7 ] && /usr/bin/env chdiff --wait "$2" "$5"

Save that to a script (for example, name it git-external-chdiff) and then set the GIT_EXTERNAL_DIFF environment variable to point at the script's location. Once set, running git diff or git diff filename will invoke chdiff to perform the diffs. Removing the --wait flag to chdiff causes a Changes.app warning dialog about modified files to sometimes appear. If you choose to remove the --wait flag and you get the file modification dialog click "Keep Changes Version" to continue working.

As an alternative to setting the GIT_EXTERNAL_DIFF environment variable you can run the following command:

   git config --global diff.external <path_to_wrapper_script>

Multiple file comparisons are supported. When using the --wait flag you will need to close the current window before the next one will open. Without the --wait flag all requested files will open at the same time. You can either show all changed files in your project with git diff or alternately you can specify selected files with something like git diff file1.m path/to/file2.m.


To use Changes with the 'git mergetool' command, add the following to your .gitconfig file:

   [merge]
       tool = chdiff
   [mergetool "chdiff"]
       cmd = /usr/bin/env chdiff --wait "$LOCAL" "$REMOTE"
       keepBackup = false
       trustExitCode = false

Below you will find two alternate script-based methods for invoking git diffs using chdiff.

--

A cli tool for viewing git commits in Changes: http://pastie.org/134012/ Legitimate Paid Surveys

The above could be made a lot faster by avoiding the init+pull. Something like this appears to work fairly well - http://pastie.caboo.se/154707 - and allows you to use any commit name, not just local ones (eg gitchdiff -rmaster:origin/master)

[edit] Bazaar Integration

1. Download and install the "difftools" plugin from http://bazaar-vcs.org/BzrPlugins.

2. (Optional) Edit the file difftools/controller.py and add this line near the bottom:

register_diff_tool(TreeDiffTool('chdiff', cleanup=False))

3. Add the following to your ~/.bazaar/bazaar.conf file:

[ALIASES]
chdiff = diff --using chdiff

If you left out step 2, this should instead read:

[ALIASES]
chdiff = diff --using chdiff --diff-options --wait

Note that this way, you will have to quit Changes.app before bzr returns. Please see essay

4. You should now be able to run bzr chdiff in your local Bazaar branch just like you would bzr diff.

[edit] Darcs Integration

To use Changes with Darcs, just use this command line:

darcs diff --diff-command "chdiff %1 %2"

You can make Changes the default by adding this line to your ~/.darcs/defaults or $REPO/_darcs/prefs/defaults:

diff diff-command chdiff %1 %2

[edit] Discussion

Moderator Note: Please use Talk:SCM_Integration_Scripts to discuss the information on this hosting WoW Leveling Guide page on pool covers

[edit] Bounty

If you post a script or instructions up here for a version control system, please contact me at support@(the main site's domain) to claim your complimentary license for Changes 1.0 when it ships.