(Sorry to flood people's inboxes... I'm a little verbose when it comes
to design issues.)
After thinking about the general unreadability of my proposed format,
I thought I would go through and make a DTD and sample delta for Greg
Stein's XML format proposal. If you go to the end of this message and
look at the sample, you can see that it's considerably more readable,
although it's maybe less clear to the uninitiated that you need to
"add-file" or "replace-file" before you can "text-delta".
except that the lookup strings for file and directory batons are parts
of the pathnames. For instance, when the parser runs into something
like:
<add-dir path="/A/B/C"/>
it will rip apart the path into a parent directory "/A/B" and a new
directory name "C". "/A/B" will be used to look up the parent
directory baton. For file-editing calls like text-delta, the entire
path gets used as a lookup string for the file baton.
Comparison:
* Greg Stein's approach is more readable.
* Greg Stein's approach becomes really verbose when directory
names get long. My approach doesn't have this problem
because IDs can be a lot shorter than pathnames.
* My approach makes the constraints clearer, since you can't
try to <text-delta> a file before you specify an ID for it.
* My approach is a little cleaner from an implementation point
of view since you don't have to rip apart paths. (But there
is a middle-ground approach where you specify the parent
path and directory element in separate attributes, so if
this is a real issue it only requires a tweak to my
rendition of Greg Stein's proposal.)
So, opinions? At the moment I'm leaning in favor of Greg Stein's
approach, long directory names be damned. But I'll take a break for a
few hours and let people catch up before I start trying to crank out
an implementation.
<?xml version="1.0" encoding="UTF-8"?>
<!-- XML DTD for Subversion's delta packages. -->
<!ELEMENT delta-pkg (delete | add-dir | replace-dir | change-dir-prop
| change-dirent-prop | close-dir | add-file
| replace-file | text-delta | change-file-prop
| close-file)*>
<!-- delete-dirent: delete a directory entry -->
<!ELEMENT delete-dirent>
<!ATTLIST delete-dirent
path CDATA #REQUIRED
>
<!-- add-dir: Create a new directory -->
<!ELEMENT add-dir>
<!ATTLIST add-dir
path CDATA #REQUIRED
ancestor CDATA #IMPLIED
ancver CDATA #IMPLIED
>
<!-- replace-dir: Modify a directory -->
<!ELEMENT replace-dir>
<!ATTLIST replace-dir
path CDATA #REQUIRED
ancestor CDATA #IMPLIED
ancver CDATA #IMPLIED
>
<!-- change-dir-prop: Edit the properties of a directory -->
<!ELEMENT change-dir-prop (set | delete)+>
<!ATTLIST change-dir-prop
path CDATA #REQUIRED
>
<!-- change-dirent-prop: Edit the properties of a directory entry -->
<!ELEMENT change-dirent-prop (set | delete)+>
<!ATTLIST change-dirent-prop
path CDATA #REQUIRED
>
<!-- close-dir: Indicate that we are done with a directory -->
<!ELEMENT close-dir>
<!ATTLIST close-dir
path CDATA #REQUIRED
>
<!-- add-file: Create a new file -->
<!ELEMENT add-file>
<!ATTLIST add-file
path CDATA #REQUIRED
ancestor CDATA #IMPLIED
ancver CDATA #IMPLIED
>
<!-- replace-file: Modify a file -->
<!ELEMENT replace-file>
<!ATTLIST replace-file
path CDATA #REQUIRED
ancestor CDATA #IMPLIED
ancver CDATA #IMPLIED
>
<!-- text-delta: Edit the text of a file -->
<!ELEMENT text-delta (#PCDATA)>
<!ATTLIST text-delta
path CDATA #REQUIRED
>
<!-- change-file-prop: Edit the properties of a file -->
<!ELEMENT change-file-prop (set | delete)+>
<!ATTLIST change-file-prop
path CDATA #REQUIRED
>
<!-- close-file: Indicate that we are done with a file -->
<!ELEMENT close-file>
<!ATTLIST close-file
path CDATA #REQUIRED
>
<!-- set: Set a property's value -->
<!ELEMENT set (#PCDATA)>
<!ATTLIST set
name CDATA #REQUIRED
>
<!-- delete: Delete a property -->
<!ELEMENT delete EMPTY>
<!ATTLIST delete
name CDATA #REQUIRED
>
<?xml version="1.0" encoding="UTF-8"?>
<delta-pkg>
<add-dir path="/A" ancestor="/A" ancver="1"/>
<add-file path="/A/mu" ancestor="/A/mu"/>
<text-delta path="/A/mu">This is the file 'mu'.</text-delta>
<close-file path="/A/mu"/>
<add-dir path="/A/B" ancestor="/A/B"/>
<add-file path="/A/B/lambda" ancestor="/A/B/lambda"/>
<text-delta path="/A/B/lambda">This is the file 'lambda'.</text-delta>
<close-file path="/A/B/lambda"/>
<add-dir path="/A/B/E" ancestor="/A/B/E"/>
<change-dir-prop path="/A/B/E">
<set name="car">buick</set>
</change-dir-prop>
<close-dir path="/A/B/E"/>
<add-dir path="/A/B/F" ancestor="/A/B/F"/>
<change-dir-prop path="/A/B/F">
<delete name="glub"/>
</change-dir-prop>
<close-dir path="/A/B/F"/>
<close-dir path="/A/B"/>
<add-dir path="/A/C" ancestor="/A/C"/>
<close-dir path="/A/C"/>
<add-dir path="/A/D"/>
<add-file path="/A/D/gamma" ancestor="/A/D/gamma"/>
<change-file-prop path="/A/D/gamma">
<set name="banana">yellow</set>
<delete name="lemon"/>
<set name="crabgrass">epistemological</set>
</change-file-prop>
<text-delta path="/A/D/gamma">This is the file 'gamma'.</text-delta>
<close-file path="/A/D/gamma"/>
<close-dir dir-id="/A/D"/>
<close-dir dir-id="/A"/>
</delta-pkg>
Received on Sat Oct 21 14:36:10 2006