Re: Notebooks and CVS: how to automatically strip output?
- To: mathgroup at smc.vnet.net
- Subject: [mg33062] Re: Notebooks and CVS: how to automatically strip output?
- From: Albert Retey <albert.retey at visualanalysis.com>
- Date: Fri, 1 Mar 2002 06:51:01 -0500 (EST)
- Organization: Visual Analysis AG
- References: <a5fm1r$e1a$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, > 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). 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