I like to keep all my files in a version control system, but this system
isn't coping very well with large notebooks containing graphics etc.
At present I simply use the front end menu Kernel->Delete All Output
before saving -- but this isn't quite satisfactory.
What I need is a way to perform this action automatically from a
makefile: read a given notebook, strip the output (and cache) and write
the result to a new notebook file (which I will then send to the CVS).
Any ideas?
Janus Wesenberg
I'm not really answering because I have a good solution to your problem,
but because I have thought about the same problem myself and found that
it would take some effort to make the setup really useful, since cvs
will regard notebooks as changed even if you only open or close a
cellgroup and things like that. Also I don't think it is very helpfull
to get these <<<<< marks written right into the .nb files when you merge
versions/branches or compare files (diff). These files will not even be
opened by mathematica and you don't want to work your way to the Mathematica
Boxes to understand the diffs....
To really use the advantages of cvs you would need to generate valid
notebooks from the output of cvs mergers. Then cvs would be very useful,
so,if anyone has time to implement this am willing to test :).
Of course you can do what you were asking for and also what I have
mentioned within mathematica, and you also can run the kernel from a
command line from within a makefile, if that's a solution for you. It
should be possible to read in the .nb file even without the frontend
beeing present, but you probably have to care about throwing away
caching information and stuff like that by yourself, just have a look at
a .nb file with an editor. Then something like
DeleteCases[notebook,Cell[_,"Output"|"Graphics",___]] on the
Notebook-Structure for Output and Graphics Cells should be possible,
more sophisticated patterns to decide whether to delete cells or not are
of course also possible. I have no idea about how fast such an approach
would be, but it could be a first step...
After that maybe one could close all subgroups. And then...
If anyone found a good solution to do (automated) version control for
mathematica notebooks I would be very interested...
Albert
Janus Wesenberg <jaw_r...@nospam.ifa.au.dk> writes:
> What I need is a way to perform this action automatically from a
> makefile: read a given notebook, strip the output (and cache) and write
> the result to a new notebook file (which I will then send to the CVS).
>
> Any ideas?
I have written a Perl script (called `rmnbcache') that strips all cache
data from a Mathemetica notebook (i.e., ImageCache, ImageRangeCache,
CellTagsIndex, NotebookOutline, etc.). This reduces the file size and
prevents cvs from being confused by irrelevant differences in cache data.
Thus you can say something like this in your Makefile:
strip: $(NOTEBOOKS)
rmnbcache $(NOTEBOOKS)
We are using this Perl script for several years now in our group to commit
notebooks to our cvs repository.
Additionally we have a Perl script called `testnbcache' which is called by
cvs (using `commitinfo'). This script denies commiting of notebook files
which have not been stripped.
If someone is interested in these Perl scripts, please contact me. I will
then send you the files by email.
Best regards,
Tim
--
Tim Wichmann, wich...@itwm.fhg.de
Fraunhofer Institute for Industrial Mathematics
D-67663 Kaiserslautern, Germany
Tel: +49(0)631/205-4475, Fax: ~-4139
I have added the perl scripts `rmnbcache' and `testnbcache' for download to
our web page. You can find them in the section "Mathematica Notebook Files
and Version Control Systems" at
http://www.analog-insydes.de/utilities.html
There you will also find documentation on how to use them.
Best regards,
Tim.
--
Tim Wichmann, wich...@itwm.fhg.de
Fraunhofer Institute for Industrial Mathematics
D-67663 Kaiserslautern, Germany