Commit 82514f73 authored by Barry Warsaw's avatar Barry Warsaw

write_object_undo(): Use this method instead of write_moved_object()

to record an undo transaction for an object.  This will remember the
previous revids for the undone objects, which is necessary because a
transaction may undo several revisions of an object.

get_prevrevid(): Given an oid, get the recorded previous revid for the
object.
parent 1c74bda2
......@@ -328,10 +328,12 @@ class FullLog(CommitLog):
"""Initialize the `full' commit log, usually with a new file."""
CommitLog.__init__(self, file, dir)
self.__versions = {}
self.__prevrevids = {}
def finish(self):
CommitLog.finish(self)
self.__versions.clear()
self.__prevrevids.clear()
def get_vid(self, version, missing=None):
"""Given a version string, return the associated vid.
......@@ -339,6 +341,17 @@ class FullLog(CommitLog):
"""
return self.__versions.get(version, missing)
def get_prevrevid(self, oid, missing=None):
"""Given an object id, return the associated prevrevid.
If not present, return `missing'.
This method serves to allow transactionalUndo() to find undone
transactions that have been committed to the log, but not to the
database (i.e. multiple transactionalUndo()'s during a single
transaction).
"""
return self.__prevrevids.get(oid, missing)
# read/write protocol
def write_object(self, oid, vid, nvrevid, pickle, prevrevid):
......@@ -357,6 +370,13 @@ class FullLog(CommitLog):
# reuse the pickle already in the database.
self._append('o', (oid, vid, nvrevid, lrevid, '', prevrevid))
def write_object_undo(self, oid, vid, nvrevid, lrevid, prevrevid):
# Identical to write_moved_object() except that we have to keep some
# extra info around. Specifically, it's possible to undo multiple
# transactions in the same transaction.
self._append('o', (oid, vid, nvrevid, lrevid, '', prevrevid))
self.__prevrevids[oid] = prevrevid
def write_new_version(self, version, vid):
self._append('v', (version, vid))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment