Getting started with a content filter

Martin Pool mbp at canonical.com
Tue Jul 26 05:46:00 UTC 2011


On 26 July 2011 03:56, Anteru <newsgroups at catchall.shelter13.net> wrote:
> Hi,
>
> I'm trying to write a content filter and there's a bunch of things I
> don't get yet:
>
> * How do I specify for which files the content filter should be run? It
> seems the rules file is the right place for this. I can add a section
> like this there ...
>
> [name *.bin]
> binstore = on
>
> but is there a way to get more complex rules via Bazaar? In my case, I'd
> like to enable it for file X only (by adding some metadata to a file.)
> If there is no way to attach it to a file, can files in the repository
> be uniquely identified?

You can look up per-branch configuration options if you want to let
users control what is stored or where.  But based on the previous
discussion it seemed to me that you'd probably want to have a file in
.bzrmeta that gives some additional files that ought to be checked
out, and the places to put them at?

> * The file contents are passed to the content filter as chunks, which
> are strings. That basically forces me to have the whole file in memory.
> Is there a way to obtain a stream-interface to the file instead of the
> file contents?

The idea is that the stream can be a generator and then you don't need
the whole thing in memory at one time.  (This might not be perfectly
achieved but that's the idea.)

> * What is the recommended way to get debug output out of my plugin?
> bzrlib.trace? Is there something else specific for debugging?

trace.mutter; if you think this will generate large amounts of output
then you should make it conditional

  if 'binstore' in debug.debug_flags:
    mutter('unpack %s in %s') ...

Martin



More information about the bazaar mailing list