Update of /cvsroot/zxsync/zXSync/zxsync
In directory sc8-pr-cvs1:/tmp/cvs-serv30314
Modified Files:
syncbase.py
Log Message:
- Added automatic sync mode assignment based on the backups
- Bug fixes for cloning (some attributes were not copied)
Index: syncbase.py
===================================================================
RCS file: /cvsroot/zxsync/zXSync/zxsync/syncbase.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** syncbase.py 23 Jun 2003 21:16:29 -0000 1.5
--- syncbase.py 13 Jul 2003 09:13:01 -0000 1.6
***************
*** 29,32 ****
--- 29,38 ----
SYNC_DELETE = 4
+ STATUS_UNKNOWN = 0
+ STATUS_UNCHANGED = 1
+ STATUS_CHANGED = 2
+ STATUS_ADDED = 3
+ STATUS_DELETED = 4
+
WRITE_SINGLE = 1 # the plugin wants to write single entries
WRITE_ALL = 2 # the plugin wants to write all entries at once
***************
*** 56,59 ****
--- 62,66 ----
"""
self.syncMode = SYNC_BOTH
+ self.status = STATUS_UNKNOWN
self.children = []
self.parent = None
***************
*** 77,80 ****
--- 84,88 ----
"""
other.syncMode = self.syncMode
+ other.status = self.status
other.parent = None
other.id = self.id
***************
*** 308,311 ****
--- 316,337 ----
+ def getStatus(self):
+ """
+ Returns the status of this element.
+ """
+ return self.status
+
+
+ def setStatus(self, status, modifyChildren = 1):
+ """
+ Sets the status of this element. If "modifyChildren" is true, the
+ children of this element is also modified.
+ """
+ if modifyChildren:
+ for child in self.children:
+ child.setStatus(status, 1)
+ self.status = status
+
+
def getChildren(self):
"""
***************
*** 469,472 ****
--- 495,511 ----
+ def __getstate__(self):
+ retVal = self.__dict__.copy()
+ del retVal["clonedElement"]
+ del retVal["originalElement"]
+ return retVal
+
+
+ def __setstate__(self, state):
+ self.__dict__.update(state)
+ self.clonedElement = None
+ self.originalElement = None
+
+
def __repr__(self):
return repr(self.children)
***************
*** 482,485 ****
--- 521,542 ----
"""
+ def __init__(self, id = None):
+ """
+ Initializes the application.
+ """
+ self.source = None
+ self.deviceInfo = None
+ HierarchyElement.__init__(self, id)
+
+
+ def doClone(self, other):
+ """
+ Internal clone implementation for this class.
+ """
+ other.source = self.source
+ other.deviceInfo = self.deviceInfo
+ return HierarchyElement.doClone(self, other)
+
+
def clone(self):
"""
***************
*** 536,539 ****
--- 593,609 ----
+ def __getstate__(self):
+ retVal = HierarchyElement.__getstate__(self)
+ del retVal["source"]
+ del retVal["deviceInfo"]
+ return retVal
+
+
+ def __setstate__(self, state):
+ HierarchyElement.__setstate__(self, state)
+ self.source = None
+ self.deviceInfo = None
+
+
class Entry(HierarchyElement):
"""
***************
*** 541,544 ****
--- 611,630 ----
"""
+ def __init__(self, id = None):
+ """
+ Initializes the application.
+ """
+ self.previousEntry = None
+ HierarchyElement.__init__(self, id)
+
+
+ def doClone(self, other):
+ """
+ Internal clone implementation for this class.
+ """
+ other.previousEntry = self.previousEntry
+ return HierarchyElement.doClone(self, other)
+
+
def clone(self):
"""
***************
*** 547,550 ****
--- 633,664 ----
return self.doClone(Entry())
+
+ def setPreviousEntry(self, previousEntry):
+ """
+ Sets the previous version of this entry (loaded from a backup).
+ """
+ self.previousEntry = previousEntry
+
+
+ def getPreviousEntry(self):
+ """
+ Returns the previous version of this entry (loaded from a backup).
+ This can (and should!) be used for matching if it's not None. This
+ way, changes to fields that influence the matching process are
+ handled correctly.
+ """
+ return self.previousEntry
+
+
+ def __getstate__(self):
+ retVal = HierarchyElement.__getstate__(self)
+ del retVal["previousEntry"]
+ return retVal
+
+
+ def __setstate__(self, state):
+ HierarchyElement.__setstate__(self, state)
+ self.previousEntry = None
+
class Field(HierarchyElement):
|