From 79713159cdb78fc17f48c7cd2ad34c130a33fb96 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 15 Dec 2011 08:33:19 +0000 Subject: [PATCH] schdiff, a graphical diff tool for schematics. Closes-bug: lp-1442898 --- NEWS | 4 +++ utils/README | 6 ++++ utils/docs/Makefile.am | 2 +- utils/docs/schdiff.1 | 80 +++++++++++++++++++++++++++++++++++++++++++++++ utils/scripts/Makefile.am | 4 +-- utils/scripts/schdiff | 64 +++++++++++++++++++++++++++++++++++++ 6 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 utils/docs/schdiff.1 create mode 100644 utils/scripts/schdiff diff --git a/NEWS b/NEWS index 576ac829b..1efffb556 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,10 @@ Notable changes in gEDA/gaf 1.7.2 platforms, including Windows. The `locate' tool is no longer used to search for component documentation files. +* The `schdiff' tool for generating visual diffs of schematics and + symbols has been added. It can be used with most version control + systems. See `man schdiff' for more details. + * The `bom' and `bom2' backends to `gnetlist' now give error messages if no attribute file can be found. The `-O attrib_file=FILE' and `-O attribs=ATTRIB,ATTRIB...' options have also been added. diff --git a/utils/README b/utils/README index d8772069a..6d23ee8f4 100644 --- a/utils/README +++ b/utils/README @@ -218,6 +218,12 @@ README for utilities garchive requires python to run. Run: garchive -h for help information. + + schdiff + Alan Somers + This script is used to produce graphical diffs of gschem files. It + integrates with Git, Mercurial, and Subversion. It requires ImageMagick + to run. Run schdiff -h for usage instructions. - License diff --git a/utils/docs/Makefile.am b/utils/docs/Makefile.am index 53c23be6d..70cd8f5ea 100644 --- a/utils/docs/Makefile.am +++ b/utils/docs/Makefile.am @@ -15,7 +15,7 @@ else @echo 'The documentation cannot be built from the sources.' endif -dist_man_MANS = gsch2pcb.1 grenum.1 gxyrs.1 refdes_renum.1 +dist_man_MANS = gsch2pcb.1 grenum.1 gxyrs.1 refdes_renum.1 schdiff.1 # Rules for converting man->html diff --git a/utils/docs/schdiff.1 b/utils/docs/schdiff.1 new file mode 100644 index 000000000..975cbfeb6 --- /dev/null +++ b/utils/docs/schdiff.1 @@ -0,0 +1,80 @@ +.TH schdiff 1 "December 11th, 2011" "gEDA Project" 1.7.1.20110619 + +.SH NAME +.B schdiff +\- Graphical diff tool for schematics + +.SH SYNOPSIS +.B schdiff +.I infile1.sch infile2.sch + + +.SH DESCRIPTION + +The +.B schdiff +program will use +.B ImageMagick(1) +to display a graphical diff of two gschem schematic files. It's most useful +when combined with a revision control system so it can compare two revisions of +the same file, review changes, etc. However, it is limited in that it can only +compare two files at a time; it cannot diff entire directories nor can it diff +an entire revision (unless that revision affected only one file). It can +easily be configured to work with most revision control systems. Here are +instructions for three: + +.B git: +Use the +.B difftool +command exactly as you would use +.B diff +, but supply the +.B \-x schdiff +option. + +.B mercurial: +Use the +.B schdiff +command exactly as you would use +.B diff +, but add the following lines to your .hgrc: + +.RS + [extensions] + hgext.extdiff = + [extdiff] + cmd.schdiff = schdiff +.RE + +.B subversion: +Use the +.B diff +command like normal, but supply the +.B --diff-cmd schdiff +option. + +.SH EXAMPLES + +.TP +Use git to view the changes to a file between two revisions +git difftool -x schdiff 182110f690c51eb53ea1799fd022e87322d742e3 039e012397f2638d1577dd7c80fb862a5503dbfd cpu.sch + +.TP +Use mercurial to see all the changes since a specific revision +hg schdiff -r 8442880f9835 cpld.sch + +.TP +Use subversion to review a specific revision +svn diff --diff-cmd schdiff -c 49 power.sch + +.SH BUGS + +If you find one, please report it at https://bugs.launchpad.net/geda + +.SH AUTHOR + +Alan Somers + +.SH SEE ALSO + +.B composite(1), display(1), git(1), gschem(1), hg(1), svn(1) diff --git a/utils/scripts/Makefile.am b/utils/scripts/Makefile.am index 5ab45274a..76e629b77 100644 --- a/utils/scripts/Makefile.am +++ b/utils/scripts/Makefile.am @@ -4,12 +4,12 @@ bin_SCRIPTS = sarlacc_sym gschupdate gsymupdate refdes_renum \ tragesym pads_backannotate pcb_backannotate garchive gsymfix.pl \ - gnet_hier_verilog.sh + gnet_hier_verilog.sh schdiff EXTRA_DIST = convert_sym.awk gpstoimage mk_char_tab.pl \ sarlacc_sym gschupdate gsymupdate refdes_renum gsymfix.pl \ tragesym pads_backannotate pcb_backannotate garchive.py \ - gnet_hier_verilog.sh + gnet_hier_verilog.sh schdiff ## SDB's stuff to enable garchive. This hardcodes the path to the ## system libraries into garchive prior to installation. diff --git a/utils/scripts/schdiff b/utils/scripts/schdiff new file mode 100644 index 000000000..8027bfc87 --- /dev/null +++ b/utils/scripts/schdiff @@ -0,0 +1,64 @@ +#! /bin/sh + +usage () +{ + echo Usage: + echo \\tschdiff firstfile secondfile + echo \\tView a graphical diff of gschem schematics + echo + echo \\tTo use with git, just place this script in your PATH and do + echo \\tgit difftool -x schdiff ... + echo + echo \\tTo use with mercurial, add the following lines to your .hgrc: + echo \\t\\t[extensions] + echo \\t\\thgext.extdiff = + echo \\t\\t[extdiff] + echo \\t\\tcmd.schdiff = /PATH/TO/schdiff + echo \\tthen to invoke it, do + echo \\thg schdiff ... + echo + echo \\tTo use with subversion, place it in your PATH and do + echo \\tsvn diff --diff-cmd schdiff ... + + echo \\tRequirements: Imagemagick and gschem be installed +} + +for PROG in gschem composite display +do + if which $PROG > /dev/null + then + true + else + echo "$PROG is not found. Either it is not installed, or not in your PATH" + exit 1 + fi +done + +if test $# -lt 2 + then usage; exit 1 +fi + +#In case the script was invoked with extra option arguments, throw them away +shift `expr $# - 2` + +if test -d $1 -o -d $2 + then echo "ERROR: schdiff cannot diff entire directories" + exit 1 +fi + +LEFTFILE=$1 +RIGHTFILE=$2 + +GEDASCHEMEDIR=share/gEDA/scheme +SCHEMEFILE=`dirname $0`/../${GEDASCHEMEDIR}/schdiff-image.scm +LEFTPNG=`mktemp --tmpdir schdiff.XXXXXXXXXX` +RIGHTPNG=`mktemp --tmpdir schdiff.XXXXXXXXXX` +DIFFPNG=`mktemp --tmpdir schdiff.XXXXXXXXXX` + +gschem -p -o $LEFTPNG -q -c '(image-size 1344 1008) (image-color "disabled") (gschem-use-rc-values) (gschem-image "dummyfilename") (gschem-exit)' $LEFTFILE && \ +gschem -p -o $RIGHTPNG -q -c '(image-size 1344 1008) (image-color "disabled") (gschem-use-rc-values) (gschem-image "dummyfilename") (gschem-exit)' $RIGHTFILE && \ +composite -stereo 0 $LEFTPNG $RIGHTPNG $DIFFPNG && \ +display $DIFFPNG +rm $LEFTPNG +rm $RIGHTPNG +rm $DIFFPNG -- 2.11.4.GIT