Skip to content

Instantly share code, notes, and snippets.

@chriswk
Created August 30, 2010 13:33
Show Gist options
  • Save chriswk/557396 to your computer and use it in GitHub Desktop.
Save chriswk/557396 to your computer and use it in GitHub Desktop.
public String diff(String file, String left, String right)
throws IOException, SubversionException {
if (log.isDebugEnabled()) {
log.debug("diff " + file + " " + left + " " + right);
}
StringBuffer tag1 = new StringBuffer().append(getValue("svn.document.root"));
if (MAINBOOK.equals(type)) {
tag1.append(getValue("svn.tags.path"));
} else if (PASIENT.equals(type)) {
tag1.append(getValue("svn.tags.pasient.path"));
} else if (VETERINAR.equals(type)) {
tag1.append(getValue("svn.tags.vet.path"));
} else {
throw new SubversionException("Type " + type + " unknown");
}
tag1.append('/');
if (left == null) {
// Then we want latest live
tag1.append(getLatestLiveTag());
} else {
tag1.append(left);
}
StringBuffer tag2 = new StringBuffer().append(getValue("svn.document.root"));
if (right == null) {
// Then we want latest test
if (MAINBOOK.equals(type)) {
tag2.append(getValue("svn.trunk.path"));
} else if (PASIENT.equals(type)) {
tag2.append(getValue("svn.trunk.pasient.path"));
} else if (VETERINAR.equals(type)) {
tag2.append(getValue("svn.trunk.vet.path"));
} else {
throw new SubversionException("Type " + type + " unknown");
}
} else {
if (MAINBOOK.equals(type)) {
tag2.append(getValue("svn.working.tag.path"));
} else if (PASIENT.equals(type)) {
tag2.append(getValue("svn.working.tag.pasient.path"));
} else if (VETERINAR.equals(type)) {
tag2.append(getValue("svn.working.tag.vet.path"));
} else {
throw new SubversionException("Type " + type + " unknown");
}
tag2.append('/');
tag2.append(right);
}
String[] command = new String[]{"svn",
"diff",
"--diff-cmd",
getValue("svn.diff.path"),
tag1.append("/web/content").append(file).toString(),
tag2.append("/web/content").append(file).toString()};
Iterator iter = run(command).iterator();
StringBuffer content = new StringBuffer();
if (iter.hasNext()) {
// Strip the first two lines off - svn's diff header info
iter.next();
iter.next();
while (iter.hasNext()) {
content.append((String) iter.next()).append('\n');
}
}
return content.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment