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

@@ -30,7 +30,7 @@ use strict;
use warnings;
use File::Copy;
use File::Path;
use Test::More tests => 28;
use Test::More tests => 33;
mkdir("1", 0755);
mkdir("2", 0755);
@@ -136,6 +136,36 @@ $output = qx{../src/task rc:1.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/Retaining/, "Must not retain changes");
# Merges 1
$output = qx{../src/task rc:2.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/Retaining/, "Must not retain changes");
# now all three instances must be in sync
$output = qx{diff 1/undo.data dropbox/undo.data};
ok ($? == 0, 'Resource 1 up-to-date check');
$output = qx{diff 2/undo.data dropbox/undo.data};
ok ($? == 0, 'Resource 2 up-to-date check');
$output = qx{diff 3/undo.data dropbox/undo.data};
ok ($? == 0, 'Resource 3 up-to-date check');
## Merges 3
#$output = qx{../src/task rc:3.rc merge 2>&1};
#ok ($? == 0, 'Exit status check');
#unlike ($output, qr/Retaining/, "Must not retain changes");
#
## Merges 1
#$output = qx{../src/task rc:1.rc merge 2>&1};
#ok ($? == 0, 'Exit status check');
#unlike ($output, qr/Retaining/, "Must not retain changes");
#
## Merges 1
#$output = qx{../src/task rc:2.rc merge 2>&1};
#ok ($? == 0, 'Exit status check');
#unlike ($output, qr/Retaining/, "Must not retain changes");
# Cleanup.
unlink qw(1.rc 1/pending.data 1/completed.data 1/undo.data 1/backlog.data 1/synch.key 2/pending.data 2/completed.data 2/undo.data 2.rc 2/backlog.data 2/synch.key dropbox/completed.data dropbox/pending.data dropbox/undo.data 3/pending.data 3/undo.data 3/completed.data 3/backlog.data 3/synch.key 3.rc);
ok (! -r '1/pending.data' &&