Page MenuHomePhabricator
Paste P1732

arc_preview
ActivePublic

Authored by sshannin on Mar 4 2015, 6:33 PM.
Referenced Files
F329617: arc_preview
Mar 4 2015, 6:33 PM
Subscribers
None
#!/bin/bash
set -e
usage ()
{
echo "Usage: arc_preview [ -d Diff ID ]"
echo ""
echo "Will detect your local arc Diff ID and your local svn repo"
echo "to provide a diff of what has changed. This semantically"
echo "should tell you what has changed since your last 'arc diff'."
echo "If -d is provided, it will be used as the Diff ID rather than"
echo "detecting and using your most recent diff."
exit 1
}
diff=""
while getopts ":d:" opt; do
case "$opt" in
d) diff=$OPTARG
;;
*)
usage
;;
esac
done
if [ -z "$diff" ];
then
diff=`arc which | grep -o "D[1-9][0-9]*"`
fi
base_checkout=`svn info | grep ^URL | cut -d" " -f2`
if [ -z "$diff" ];
then
echo "Unable to find diff for working directory"
exit
fi
if [ -z "$base_checkout" ];
then
echo "Unable to find svninfo for working directory"
exit
fi
echo "Diff is $diff"
echo "Base Revision is $base_checkout"
curr_dir=`pwd`
## start with a fresh tmp dir
tmp_dir=`mktemp -d`
function cleanup {
rm -rf $tmp_dir
}
trap 'cleanup' EXIT
## checkout the base revision and apply the patch
svn co $base_checkout $tmp_dir --quiet
cd $tmp_dir
## patch it up and hide some noise
arc patch --force ${diff} | grep -v "^patching file" |
grep -v "^[A|U|D] "
cd $curr_dir
## perform our diff
diff -ru $tmp_dir $curr_dir --exclude=".svn"

Event Timeline

sshannin changed the title of this paste from untitled to arc_preview.
sshannin updated the paste's language from autodetect to bash.
sshannin added a project: Arcanist.