Fixed some other merge issues with the sorting order of equally timestamped
entries in undo.data (see #1104).

1. The fact that both files can begin with equal timestamps but different
   modifications has not been taken into account.

2. Besides the fact that the relative order within the same data file must
   be preservered as introduced before, we also need a unique order for entries
   of different data files so that each machine comes to the same merge result.
   This has now been achieved by taking the UUIDs into account as soon as the
   timestamps are equal.
This commit is contained in:
Johannes Schlatow
2012-11-22 00:11:53 +01:00
parent 69b63189f6
commit 0e28374131
5 changed files with 201 additions and 26 deletions

View File

@@ -39,7 +39,12 @@ bool compareTaskmod (Taskmod first, Taskmod second)
{
if (first._timestamp == second._timestamp)
{
return first._sequenceNumber < second._sequenceNumber;
// preserve relative order within the same resource
if (first._resource == second._resource)
return first._sequenceNumber < second._sequenceNumber;
// sort by UUID if mods where made on different resources
else
return first._resource < second._resource;
}
else
{
@@ -54,6 +59,16 @@ Taskmod::Taskmod ()
_bAfterSet = false;
_bBeforeSet = false;
_sequenceNumber = curSequenceNumber++;
_resource = -1;
}
Taskmod::Taskmod (int resourceID)
{
_timestamp = 0;
_bAfterSet = false;
_bBeforeSet = false;
_sequenceNumber = curSequenceNumber++;
_resource = resourceID;
}
////////////////////////////////////////////////////////////////////////////////
@@ -65,6 +80,7 @@ Taskmod::Taskmod (const Taskmod& other)
this->_bAfterSet = other._bAfterSet;
this->_bBeforeSet = other._bBeforeSet;
this->_sequenceNumber = other._sequenceNumber;
this->_resource = other._resource;
}
////////////////////////////////////////////////////////////////////////////////
@@ -108,7 +124,8 @@ Taskmod& Taskmod::operator= (const Taskmod& other)
this->_timestamp = other._timestamp;
this->_bAfterSet = other._bAfterSet;
this->_bBeforeSet = other._bBeforeSet;
this->_sequenceNumber = other._sequenceNumber;
this->_sequenceNumber = other._sequenceNumber;
this->_resource = other._resource;
}
return *this;
@@ -225,6 +242,12 @@ unsigned long Taskmod::getSequenceNumber () const
return _sequenceNumber;
}
////////////////////////////////////////////////////////////////////////////////
int Taskmod::getResource () const
{
return _resource;
}
////////////////////////////////////////////////////////////////////////////////
std::string Taskmod::getTimeStr () const
{