[PATCH] check for control directory when initializing branch
Aaron Bentley
aaron.bentley at utoronto.ca
Tue May 17 15:24:39 BST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David Clymer wrote:
| This just adds a check for the existance of a controlfile directory
| before attempting to initialise a branch.
How about something more like:
class AlreadyInitialized(Exception):
~ def __init__(self, dir):
self.dir = dir
~ Exception.__init__("Directory %s is already initialized", dir)
~ def _make_control(self):
~ try:
~ os.mkdir(self.controlfilename([]))
~ except IOError, e:
~ if e.errno == errno.EEXIST:
~ raise AlreadyInitialized(dir)
~ else:
~ raise
~ self.controlfile('README', 'w').write(
~ "This is a Bazaar-NG control directory.\n"
Catching EEXIST errors means that there's no chance for a race condition.
Throwing a specific error means that higher-level code can make
intelligent decisions about how to handle it.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCif6n0F+nu1YWqI0RAp20AJ9KpCgmBhp+JCbDXZvkX8vNa8bROgCfesMq
8NZVtU6QcoMWiuJwIwAnIAA=
=O/oE
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list