Current data file incompatibility of branch-2.0 vs. SVN-trunk
Christian Stimming
stimming at tuhh.de
Sun Feb 18 06:40:26 EST 2007
Ok, maybe it's just me, but I've been hit by the recent "data file
compatibility" discussion, and it came as quite a surprise.
Problem description: I've been working on a data file (which contains a small
number of scheduled transactions) by SVN-trunk and later tried to open the
same data file with the current SVN-branch/2.0. When trying to open the file
in branch-2.0, I get the error dialog "There was an error parsing the
file /my/file/name." [1] and gnucash just shows an empty window. On the
command line, I see several tens of lines like these:
<gnc:schedxaction version="1.0.0">
<sx:id type="guid">f79b0b0a55fa114e2852db2a33e5da6c</sx:id>...
but this also doesn't say what is going on.
What has happened: Turns out in r15486 [2] Peter McAlpine added the
<sx:enabled>y</sx:enabled> field to the <gnc:schedxaction...> sections, and
because the branch-2.0 code of the XML parser doesn't know the sx:enabled
field, it will refuse to load this data file altogether.
My suggestions:
* First of all, I would like to have a quick'n'dirty solution for us
developers who frequently swith back and forth between SVN-trunk and
branch-2.0, but still want to use the same data file. This could even be an
external command line script [3], but it should be in SVN anyway so that we
keep track of what it does.
* Secondly, the error message of the parser error needs to be revised to be
much more helpful. IIRC the parser itself is a problem here, as it either
reads all or nothing. But at least we should extend the user message into
something like this:
"There was an error parsing the file /my/file/name, although the file could
be loaded correctly [making sure people can distinguish this error from file
permission problems]. This probably means the file has been saved by a newer
version of gnucash and cannot be parsed by this older version because of new
data elements. "
If we had the abovementioned command line script available, we might even add
a suggestion of what to do: "If you want to remove the new data elements,
please use the program 'gnucash-datafile-stripnew-justwhatevername' of the
newer gnucash version, then open the data file again in this version."
* Thirdly, as 2.0.x is still around for some months to come, we really really
really need a solution here. Either one at the SVN-trunk side: "Disable new
data file elements" or, in other wording, "save data file in 2.0
compatibility mode" as a preference. Or one at the branch-2.0 side: "Ignore
unknown data file elements instead of refusing this file" either as a
preference or as one potential choice when this error message is encountered,
with a later summary of what has been ignored/removed. An extra menu
item "Export to 2.0" should IMHO rather be avoided, as nobody will notice it
or use it anyway but people will rather expect to be able to deal with this
at loading time in 2.0.
Ideas, suggestions, flames?
Christian
[1] That's the QofBackendError ERR_FILEIO_PARSE_ERROR and the message text is
in src/gnome-utils/gnc-file.c:402.
[2]
http://svn.gnucash.org/trac/changeset/15486/gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
[3] Something along these lines, but with additional sanity checks whether the
file is gzip'd and to make sure not to overwrite any existing file:
#!/bin/sh
gunzip -d $1 > $1.orig
grep -v '<sx:enabled>.</sx:enabled>' $1.orig > $1.tmp
echo "Removed the following elements:"
diff -u $1.orig $1.tmp
echo "Keeping old data file as $1.orig.gz"
gzip $1.orig
gzip -d $1.tmp > $1
rm $1.tmp
More information about the gnucash-devel
mailing list