Intelligent docbook merging?

Andrew Bennetts andrew.bennetts at canonical.com
Fri Feb 25 01:07:30 UTC 2011


Nicholas Allen wrote:
> Doesn't Bazaar have some way to convert the file that is stored on disk
> to another format that is saved in the repository without actually
> changing the file in the working tree? I seem to remember that something
> like this is used to convert text file line ending styles.
> 
> If I could hook into this mechanism then I could convert the XML file to
> a standard formatting without affecting the file in the user's working
> tree so it wouldn't matter if the file was still open in the editor. Can
> that be done with Bazaar rules? I'm looking into it now but am not that
> familiar with it yet....

There are two different approaches you can take with current bzr:

 * filtered views: store a normalised form in the repository, and have a filter
   that reads/writes it the working tree in another form.
 
 * merge hook: run custom logic when merging different versions of a file (e.g.
   first normalise the formatting then run the regular merge, or use an external
   docbook-aware merge program for specific files)

The feature you're thinking of when you refer to line ending styles is the
former.  You'd need to write and install a plugin to define the “filter”, IIRC,
then configure that in the rules file.

My inclination would probably be the latter option (but perhaps just because I'm
more familiar with it, having written the code…).  Again, you'd need to write
and install a plugin to register a merge_file_content hook.  There's a simple
example at
<http://doc.bazaar.canonical.com/latest/en/user-guide/hooks.html#example-a-merge-plugin>.

-Andrew.




More information about the bazaar mailing list