From 7029773512eee5a0bb765b82cfdd90fd5ab34e15 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 23 Nov 2010 23:20:11 +0100 Subject: Implemented revlog.append_entry as classmethod, to assure we will always actually write_append the new entry, instead of rewriting the whole file. Added file-locking and directory handling, so the implementation should be similar (enough) to the git reference implementation. Next up is to implement a way to update the reflog when changing references, which is going to be a little more complicated --- refs/symbolic.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'refs/symbolic.py') diff --git a/refs/symbolic.py b/refs/symbolic.py index 94e8d726..0d8fdfd1 100644 --- a/refs/symbolic.py +++ b/refs/symbolic.py @@ -266,8 +266,19 @@ class SymbolicReference(object): applied to this reference .. note:: As the log is parsed every time, its recommended to cache it for use - instead of calling this method repeatedly""" + instead of calling this method repeatedly. It should be considered read-only.""" return RefLog.from_file(RefLog.path(self)) + + def log_append(self, oldbinsha, message, newbinsha=None): + """Append a logentry to the logfile of this ref + :param oldbinsha: binary sha this ref used to point to + :param message: A message describing the change + :param newbinsha: The sha the ref points to now. If None, our current commit sha + will be used + :return: added RefLogEntry instance""" + return RefLog.append_entry(RefLog.path(self), oldbinsha, + (newbinsha is None and self.commit.binsha) or newbinsha, + message) @classmethod def to_full_path(cls, path): -- cgit v1.2.3