MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Why does mathematica randomly rewrite notebooks?

  • To: mathgroup at
  • Subject: [mg54904] Re: [mg54879] Re: [mg54838] Why does mathematica randomly rewrite notebooks?
  • From: John Fultz <jfultz at>
  • Date: Sun, 6 Mar 2005 00:55:55 -0500 (EST)
  • Reply-to: jfultz at
  • Sender: owner-wri-mathgroup at

Internally, we use CVS on notebooks, so making notebooks function well with 
revision control systems is an important goal to us.  CVS generally works 
fine on notebooks, with the caveat of avoiding the keyword expansion 
features, and the sometimes-difficult-to-interpret diffs.

Unfortunately, revision control diffing tools really like to assume that 
all documents are basically unstructured text documents, while notebooks do 
have structure which is hard to visualize in text-diffs and are freely 
line-wrapped by the FE in such a way that can sometimes really defeat a 
straight text diff.  Also, the file outline caches (the comments at the end 
of the file used to make speedy incremental loading of notebook possible) 
can change frequently and pollute the diffs with information that's never 
useful to see.

In fact, this isn't anything unique to notebooks.  Any structured document 
format...XML is a perfect and ubiquitous not as interesting 
when diffs are viewed textually as it is when diffs are viewed with a 
diffing tool that understands the structure.

We do have such a structural diffing tool.  Check out the NotebookDiff 
function in the AuthorTools` package.  This function requires the two 
versions of the notebooks side-by-side on your file system, but can be 
invaluable at understanding what the heck a diff actually means.  We often 
use it internally to help with our document management.

There are also a couple of bugs which do needlessly rewrite sections of the 
the notebook which will be fixed in future versions (the notebooks written 
out are correct notebooks...but the variations are not strictly necessary). 
 Additionally, we've done some work for future versions to allow cvs 
keyword expansion without throwing off the file outline cache and to allow 
complete suppression of file outline caches by default.  We continue to 
look into other means of making revision control of notebooks easier.

Also, let me correct point 1 below, which is precisely incorrect.  CVS has 
no practical line limit, and Mathematica notebook files as written by the 
FE are uniformly 78 characters or less in length (this isn't a requirement 
of the notebook format, just a convention enforced by the FE).


John Fultz
jfultz at
User Interface Group
Wolfram Research, Inc.

 On Sat, 5 Mar 2005 01:34:24 -0500 (EST), jmt wrote:
> A few remarks :
 > 1 - CVS is line oriented, and lines MUST be less than 80 characters
> long, while Mathematica notebooks make no assumptions on line length.
> This might explain the changes you have noticed.
 > 2 - Mathematica uses a cache, handling this cache in a versioning system
> can be viewed as non-sense. The company "Analog Insydes" discusses this
> point and provides a set of utilities for handling notebooks with CVS :
> I have used these utilities
> up to version 5.0 without trouble of any kind.
 > 3 - When notebooks contain some information that can be modified by the
> versioning system, the FrontEnd will report a warning. If this warning
> can oftenly be ignored, users might nevertheless have some doubt about
> the versioning strategy, and there is no way to avoid this with CVS.
 > 4 - After using CVS for some years, I switched to subversion. This
> system is much more adequate for revision control than CVS is,
> especially for files like mathematica notebooks. I do not modify the
> notebooks before storing them in the repository (meaning I do NOT strip
> the cache off, even if this can be viewed as a loss of disk resource),
> because disk space is no longer a problem and because Mathematica
> projects seldom span over hundreds of files. If I have no experience in
> migrating a project from CVS to subversion, all new projects are now
> handled by subversion.
> jmt
> On 2005 03 04 11:07, Josef Karthauser wrote:
>> I'm trying to manage mathematica notebooks in a revision control system
>> and it is really bugging me that mathematica writes notebooks with
>> trivial changes seemingly randomly.  Does anyone know why?
>> Here's an example:
>> @@ -860,7 +862,7 @@
>> \(Tuu[i, j] Xd[j] // ToFlavor[natbasis]\), "\n",
>> \(\(\(% /.
>> x : Xd[_] \[RuleDelayed] \(TransformIndexFlavor[
>> -            natbasis,
>> {\[Lambda]form}]\)[x]\)\(\n\)\(\[IndentingNewLine]\) +
>> natbasis, {\[Lambda]form}]\)[x]\)\(\[IndentingNewLine]\)\(\n\) \)
>> (*\[IndentingNewLine]\(% // SumExpansion[natbasis /@ {i, j}]\) //
>> SumExpansion[\[Lambda]form[k]]\[IndentingNewLine]%%\[IndentingNewLine]*
>> )
>> \), "\
>> The line starting with '-' shows what was there, and the line starting
>> with '+' shows that change that mathematica made at the last save.
>> Notice the at the order of the \n and the IndentingNewLine have been
>> reversed.  This appears to happen at random.
>> WRI, is there anything I can do to prevent this, or is it a
>> bug/feature?
>> Joe
>> --
>> Josef Karthauser (joe at
>> FreeBSD (cvs meister, admin and hacker)
>> Physics Particle Theory (student)

  • Prev by Date: Re: Re: Goto Line ?
  • Next by Date: Re: Why does mathematica randomly rewrite notebooks?
  • Previous by thread: Re: Why does mathematica randomly rewrite notebooks?
  • Next by thread: Re: Re: Re: Why does mathematica randomly rewrite notebooks?