3 # Tests for the doppleganger conflict bug.
10 use Test
::More
'no_plan';
25 system 'rm -rf temp/*';
29 ok
(dopplegangers_conflict
('old-fashioned-inventory'),
30 "default repo format views doppleganger as a conflict");
32 ok
(dopplegangers_conflict
('hashed'),
33 "hashed repo format views doppleganger as a conflict");
35 ok
((not dopplegangers_conflict
('darcs-2')),
36 "with darcs-2 format, doppleganger's don't conflict! ");
38 ok
(resolution_dopplegangers_conflict
('old-fashioned-inventory'),
39 "default repo format views resolution doppleganger as a conflict");
41 ok
(resolution_dopplegangers_conflict
('hashed'),
42 "hashed repo format views resolution doppleganger as a conflict");
44 ok
(not (resolution_dopplegangers_conflict
('darcs-2')),
45 "with darcs-2 format, resolution doppleganger's don't conflict! ");
48 sub dopplegangers_conflict
{
49 my $arg_to_init = shift;
50 system 'rm -rf tmp_dopple tmp_ganger';
54 darcs
'init --'.$arg_to_init;
58 'old-fashioned-inventory' => 'darcs-1.0',
59 'darcs-2' => 'darcs-2',
63 like
((darcs
'show repo'), qr/$fmts{$arg_to_init}/,
64 "reality check: $fmts{$arg_to_init} is repo format of tmp_doppel");
68 my $out = darcs
"record -A base -am 'adding a.txt'";
69 like
($out, qr/finished/msxi, "$arg_to_init: recorded patch for adding file.");
73 $out = darcs
'get tmp_dopple tmp_ganger';
74 like
($out, qr/inished getting/, 'get tmp_dopple tmp_ganger worked');
77 #like((darcs 'show repo --repodir=tmp_ganger'), qr/$fmts{$arg_to_init}/,
78 # "reality check: $fmts{$arg_to_init} is repo format for tmp_ganger");
80 for my $repo (qw(dopple ganger)) {
81 ok
((chdir "tmp_$repo"), "chdir'ed tmp_$repo");
82 `echo "text which appears in both places at once" > a.txt`;
83 my $out = darcs
"record -A $repo -am 'recording an identical change'";
84 like
($out, qr/finished/msxi, "$arg_to_init: recorded patch in $repo");
85 # diag "in loop: $out";
89 # Now that the conflict has been set up, try pull one patch from the other.
92 my $pull_out = darcs
'pull -a ../tmp_dopple';
93 my $has_a_conflict_p = ($pull_out =~ m/conflict/msxi);
94 # diag "result: $pull_out";
98 # diag "about to to return: $has_a_conflict_p";
100 return $has_a_conflict_p;
103 sub resolution_dopplegangers_conflict
{
104 my $arg_to_init = shift;
106 system 'rm -rf temp0 temp1 temp2';
108 # Map args to formats
110 'old-fashioned-inventory' => 'darcs-1.0',
111 'darcs-2' => 'darcs-2',
112 'hashed' => 'hashed',
117 darcs
'init --'.$arg_to_init;
118 like
((darcs
'show repo'), qr/$fmts{$arg_to_init}/,
119 "reality check: $fmts{$arg_to_init} is repo format of temp0");
120 #diag (darcs 'show repo');
124 darcs
'get ../temp0 temp1';
126 #diag (darcs 'show repo');
127 like
((darcs
'show repo'), qr/$fmts{$arg_to_init}/,
128 "reality check: $fmts{$arg_to_init} is repo format of temp1");
129 `echo "temp1" > a.txt`;
131 darcs
"record -A base -am 'adding a.txt'";
133 darcs
'get ../temp0 temp2';
135 #diag (darcs 'show repo');
136 `echo "temp2" > a.txt`;
138 darcs
"record -A base -am 'adding a.txt'";
141 # Resolve the conflict the same way on both sides
142 for my $repo (qw(dopple ganger)) {
143 darcs
"get temp1 tmp_$repo";
144 ok
((chdir "tmp_$repo"), "chdir'ed tmp_$repo");
145 darcs
"pull -a ../temp2";
146 `echo "text which appears in both places at once" > a.txt`;
147 my $out = darcs
"record -A $repo -am 'recording an identical change'";
148 like
($out, qr/finished/msxi, "$arg_to_init: recorded patch in $repo");
149 #diag "in loop: $out";
153 # Now that the conflict has been set up, try pull one patch from the other.
156 my $pull_out = darcs
'pull -a ../tmp_dopple';
157 #diag (darcs 'changes -v');
158 my $has_a_conflict_p = ($pull_out =~ m/conflict/msxi);
159 #diag "result: $pull_out";
165 #diag "about to to return: $has_a_conflict_p";
167 return $has_a_conflict_p;