Discussion:
Revert, but give it a different name?
Nathan Hartman
2018-08-14 16:36:10 UTC
Permalink
Suppose I modified filename.c. Can I revert, but instead of throwing away
my changes, revert to a separate file like filename.c.old and keep my
modified filename.c for comparison in my favorite tool?
Daniel Shahaf
2018-08-15 08:02:56 UTC
Permalink
Post by Nathan Hartman
Suppose I modified filename.c. Can I revert, but instead of throwing away
my changes, revert to a separate file like filename.c.old and keep my
modified filename.c for comparison in my favorite tool?
svn cat ***@BASE > filename.c.old

but a better way to achieve what you're trying to do is to use a custom diff-cmd.
Ryan Schmidt
2018-08-15 11:10:38 UTC
Permalink
Post by Daniel Shahaf
Post by Nathan Hartman
Suppose I modified filename.c. Can I revert, but instead of throwing away
my changes, revert to a separate file like filename.c.old and keep my
modified filename.c for comparison in my favorite tool?
but a better way to achieve what you're trying to do is to use a custom diff-cmd.
Right. As an example, here's the "svnbbdiff" script I use (an updated version of the "svntwdiff" script I previously posted), which opens the svn diff into the macOS text editor BBEdit; you could easily change it to open a different editor.




#!/bin/sh

# https://svn.haxx.se/users/archive-2012-04/0090.shtml

set -euo pipefail

PATH="/Applications/BBEdit.app/Contents/Helpers:$PATH"

if [ $# -lt 1 ]; then
echo "usage: $0 <file>"
exit 1
fi

FILE="$1"

if [ ! -f "${FILE}" ]; then
echo "error: ${FILE} doesn't exist"
exit 1
fi

: "${TMPDIR=/tmp}"

svn info -- "${FILE}"@ > /dev/null

TMPFILE=$(mktemp "${TMPDIR}"/svnbbdiff.XXXXXX)
trap 'rm -f -- "${TMPFILE}"' EXIT

svn cat -- "${FILE}"@BASE > "${TMPFILE}"

bbdiff --wait --resume -- "${FILE}" "${TMPFILE}"
Nathan Hartman
2018-08-15 19:45:52 UTC
Permalink
Post by Daniel Shahaf
Post by Daniel Shahaf
but a better way to achieve what you're trying to do is to use a custom
diff-cmd.
Right. As an example, here's the "svnbbdiff" script I use
Thanks, that's exactly what I needed (svn cat and the script example).

One use case (and one reason why I want to fetch the file into a working
directory) is to deal with binary formats, where it becomes necessary to
open both files in the program that understands their format and compare
visually.

Thanks again for the script. That's a good starting point.
Loading...