[RFC] Multi-level rules revisited

Ian Clatworthy ian.clatworthy at internode.on.net
Mon Jan 12 08:25:37 GMT 2009


I've been pondering rules configuration in recent days
given the feedback received to the Tree-specific rules
patch. Here's the summary of things for those who missed
the thread:

1. Global (per-user) rules are defined in BZR_HOME/rules
2. Other levels are wanted/needed, e.g. tree, branch, project
3. My patch adds support for trees (in .bzr/checkout/rules)
   only.

Ultimately, my big driver here is making Bazaar as easy to
use as possible. Rules *are* a neat foundation for stuff
like EOL support but creating and copying rules files will
suck lots. As a comparison point, enabling EOL support in
Hg is done by extending your configuration with ...

    [extensions]
    win32text =

Git is almost equally trivial.

It's relevant that rules in Bazaar are defined in INI-file
format with section headers specifying the patterns and
with the ordering of those sections being important.
For example:

  [name *.bat]
  eol = dos

  [name *]
  eol = unix

Furthermore, the global level rules are only searched
if a pattern doesn't match in a lower level file, at least
in my current patch.

To me, the #1 issue with the above so far is that rule
sharing across trees, branches and projects is going to
be painful. We *could* embed nested sections inside
projects.conf (for example) but I fear that will be
pretty messy and that other settings will get lost in
the rules noise. So ...

In this case, perhaps it's worth making the rules file
a configuration setting instead of being implicitly
found in certain locations? That would allow a few things:

1. Sharing across trees/branches/projects would be easy

2. By making the setting a comma-separated list of paths
   (say), we could limit rules to exactly the
   set of files we wanted, e.g. not search the global
   rules file unless it was given in the list.

I don't have strong feeling about 2, though it's arguably
a side effect of using a path. (Of course, if we want
the global rules file to always be searched, we could
call the setting "custom-rules-file" rather than just
"rules-file" say.)

Thoughts?

Ian C.



More information about the bazaar mailing list