Safe access to git files.
||File is already locked.|
||Ensure a directory exists, creating if necessary.|
||Create a file object that obeys the git file locking protocol.|
||File that follows the git locking protocol for writes.|
||Rename file with temporary backup file to rollback if rename fails|
def ensure_dir_exists(dirname): ¶
Ensure a directory exists, creating if necessary.
def GitFile(filename, mode='rb', bufsize=-1, mask=420): ¶
Create a file object that obeys the git file locking protocol.
Returns: a builtin file object or a _GitFile object
Note: See _GitFile for a description of the file locking protocol.
Only read-only and write-only (binary) modes are supported; r+, w+, and a are not. To read and write from the same file, you can take advantage of the fact that opening a file for write does not actually open the file you request.
The default file mask makes any created files user-writable and world-readable.
def _fancy_rename(oldname, newname): ¶
Rename file with temporary backup file to rollback if rename fails