win32 file locking
Aaron Bentley
aaron.bentley at utoronto.ca
Wed May 25 13:49:56 BST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
John A Meinel wrote:
| The problem is that Branch() is commonly used as a temporary object. For
| instance the 'bzr revno' command is done like:
|
| print Branch('.').revno()
|
| How do you unlock a branch if you never have an object to call
| 'unlock()' on?
How about this: only do permanent locks if we want them. Basically, we
have a class NewBranch where almost every method is just a decorated
call to Branch:
class NewBranch:
...
~ def lock(type):
~ self.locked_branch = Branch(self.path, type)
~ def unlock()
~ self.locked_branch.unlock()
~ self.locked_branch = None
~ def revno():
~ if self.locked_branch is not None:
~ cur_branch = self.locked_branch
~ else:
~ cur_branch = Branch(self.path, type)
~ result = cur_branch.revno()
~ if cur_branch is not self.locked_branch:
~ cur_branch.unlock()
This way
1. We don't keep any state between method calls, aside from the branch path.
2. We can still do locking when we want to.
AIUI, auto-decorating every method in Branch is pretty easy in Python.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFClHRz0F+nu1YWqI0RAkg3AJ4iM0TnrgUyH/6FFHYzGWAJCwdRPACfZPhS
1g7ck7orZDZEH9NJtUVuwfQ=
=GUdi
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list