From 61f3db7bd07ac2f3c2ff54615c13bf9219289932 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 23 Nov 2010 22:47:34 +0100 Subject: 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 --- refs/log.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'refs/log.py') 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. -- cgit v1.2.1