Reserved Edit Plugin

Martin Pool mbp at
Wed Dec 2 01:34:52 GMT 2009

2009/12/2 Simon Kersey <simon.kersey at>:
> I am developing a plugin to provide Reserved Edit functionality for Bazaar.

That would be cool, people do ask for this.  If you post it when it's
started barely working, they will give you lots of feedback, I'm sure.

> As I am new to both Bazaar and Python any feedback on the feasibility of
> the approach outlined below would be much appreciated.
> The plan is that the plugin will add 5 new commands and 2 hooks:
> red-add    - add file to reserved edit (RED) list
> red-remove - remove file from reserved edit list
> red-lock   - lock file on reserved edit list
> red-unlock - unlock file on reserved edit list
> red-ls     - list reserved edit list files in a branch (shows RED
>             files, whether they are locked, and who by
> branch pre-commit hook  - prevent commit if user has made changes to a
>                          file on the reserved edit list
>                          without having the reserved edit lock for it
> branch open hook        - make files on reserved edit list read only
>                          unless user has reserved edit lock
> The RED list itself is implemented as a set of LockDir based
> locks in a .bzr/red/locks dir in a branch identified by an environment
> variable.

I wonder if this will give you good enough messages?  I can't recall
if there's an api to put arbitrary descriptive information into the
file, but it would be possible to add one.  You might want "locked by
mbp at big search and replace, don't touch."

> I am not sure about using stat to determine the existance of the lock
> directory as a comment in the code on stat indicates that it is not supported
> on some transports.

There is LockDir(...).peek which is a more correct way to find whether
it's held or not.

> Possible performance of the branch open hook as it loops through all the
> file ids in the working tree looking for a RED lock directory.

I wouldn't worry at this stage.  I would probably do it as: get a list
of all the locks, then work through the tree and make them readonly.
If people eventually have 20,000 files individually locked, you may
need to do something for more scalability at both the format, code,
and ui levels.  (I shudder to contemplate working on such a project.

> On the plus side the prototype plugin does work.

Great!  Ship it! :-)

> PS. Thanks for having the patience to read this far.

Thanks very much for working on this.

Martin <>

More information about the bazaar mailing list