diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-23 22:47:34 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-23 22:47:34 +0100 |
commit | 61f3db7bd07ac2f3c2ff54615c13bf9219289932 (patch) | |
tree | 3074927bc62c3b4e1473d24e787836d0dfb3fa21 /refs/log.py | |
parent | a21a9f6f13861ddc65671b278e93cf0984adaa30 (diff) | |
download | gitpython-61f3db7bd07ac2f3c2ff54615c13bf9219289932.tar.gz |
Removed ORIG_HEAD handling which was downright wrong. ORIG_HEAD gets only set during merge and rebase, and probably everything that changes the ref more drastically. Probably I have to reread that. What needs to be adjusted though is the reflog
Diffstat (limited to 'refs/log.py')
-rw-r--r-- | refs/log.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/refs/log.py b/refs/log.py index 8cb0a5ab..c2799f79 100644 --- a/refs/log.py +++ b/refs/log.py @@ -1,6 +1,7 @@ from git.util import ( join_path, Actor, + LockedFD, ) from gitdb.util import ( @@ -173,13 +174,16 @@ class RefLog(list, Serializable): def to_file(self, filepath): """Write the contents of the reflog instance to a file at the given filepath. :param filepath: path to file, parent directories are assumed to exist""" - # TODO: Use locked fd - fp = open(filepath, 'wb') + lfd = LockedFD(filepath) + fp = lfd.open(write=True, stream=True) try: self._serialize(fp) - finally: - fp.close() - #END handle file streams + lfd.commit() + except: + # on failure it rolls back automatically, but we make it clear + lfd.rollback() + raise + #END handle change def append_entry(self, oldbinsha, newbinsha, message, write=True): """Append a new log entry to the revlog, changing it in place. |