Reserved Edit Plugin

Simon Kersey simon.kersey at ipl.com
Tue Dec 1 14:40:07 GMT 2009


I am developing a plugin to provide Reserved Edit functionality for Bazaar.

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.

A (very sketchy) one line summary of how each command is implemented is as 
follows:

red-add = 
  LockDir(Transport(.bzr/red/locks),file id).create
red-remove =
  LockDir(Transport(.bzr/red/locks),file id).force_break
red-lock =
  LockDir(Transport(.bzr/red/locks),file id).attempt_lock
red-unlock =
  LockDir(Transport(.bzr/red/locks),file id).unlock
red-ls =
  bzr ls but filter for existance of Transport(.bzr/red/locks).stat(file id)

pre-commit hook =
  For modified file ids stop commit if Transport(.bzr/red/locks).stat(file id)
    true and LockDir(Transport(.bzr/red/locks),file id).peek user
    not committing user

open hook = 
  For file ids in WorkingTree make read-only if 
    Transport(.bzr/red/locks).stat(file id) true and 
    LockDir(Transport(.bzr/red/locks),file id).peek user not current user

Some issues:
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.

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.

On the plus side the prototype plugin does work.

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




More information about the bazaar mailing list