improve conflict debugging

This commit is contained in:
adam 2005-12-15 11:38:36 +00:00 committed by Adam Spiers
parent 4ea5f396f9
commit c5888a964f

18
stow.in
View file

@ -381,7 +381,7 @@ sub StowDir {
&FindStowMember(sprintf('%s/%s', $Target, &FindStowMember(sprintf('%s/%s', $Target,
join('/', @dir[0..($#dir - 1)])), join('/', @dir[0..($#dir - 1)])),
$linktarget)) $linktarget))
|| (&Conflict($dir, $subdir), return); || (&Conflict($dir, $subdir, 1), return);
if (-e &JoinPaths($Stow, $stowsubdir)) { if (-e &JoinPaths($Stow, $stowsubdir)) {
if ($stowsubdir eq $dir) { if ($stowsubdir eq $dir) {
warn sprintf("%s already points to %s\n", warn sprintf("%s already points to %s\n",
@ -396,7 +396,7 @@ sub StowDir {
&StowContents($stowsubdir, &JoinPaths('..', $stow)); &StowContents($stowsubdir, &JoinPaths('..', $stow));
&StowContents($dir, &JoinPaths('..', $stow)); &StowContents($dir, &JoinPaths('..', $stow));
} else { } else {
(&Conflict($dir, $subdir), return); (&Conflict($dir, $subdir, 2), return);
} }
} else { } else {
&DoUnlink(&JoinPaths($Target, $subdir)); &DoUnlink(&JoinPaths($Target, $subdir));
@ -407,7 +407,7 @@ sub StowDir {
if (-d &JoinPaths($Target, $subdir)) { if (-d &JoinPaths($Target, $subdir)) {
&StowContents($dir, &JoinPaths('..', $stow)); &StowContents($dir, &JoinPaths('..', $stow));
} else { } else {
&Conflict($dir, $subdir); &Conflict($dir, $subdir, 3);
} }
} else { } else {
&DoLink(&JoinPaths($stow, $dir), &DoLink(&JoinPaths($stow, $dir),
@ -432,9 +432,9 @@ sub StowNondir {
&FindStowMember(sprintf('%s/%s', $Target, &FindStowMember(sprintf('%s/%s', $Target,
join('/', @file[0..($#file - 1)])), join('/', @file[0..($#file - 1)])),
$linktarget)) $linktarget))
|| (&Conflict($file, $subfile), return); || (&Conflict($file, $subfile, 4), return);
if (-e &JoinPaths($Stow, $stowsubfile)) { if (-e &JoinPaths($Stow, $stowsubfile)) {
(&Conflict($file, $subfile), return) (&Conflict($file, $subfile, 5), return)
unless ($stowsubfile eq $file); unless ($stowsubfile eq $file);
warn sprintf("%s already points to %s\n", warn sprintf("%s already points to %s\n",
&JoinPaths($Target, $subfile), &JoinPaths($Target, $subfile),
@ -446,7 +446,7 @@ sub StowNondir {
&JoinPaths($Target, $subfile)); &JoinPaths($Target, $subfile));
} }
} elsif (-e &JoinPaths($Target, $subfile)) { } elsif (-e &JoinPaths($Target, $subfile)) {
&Conflict($file, $subfile); &Conflict($file, $subfile, 6);
} else { } else {
&DoLink(&JoinPaths($stow, $file), &DoLink(&JoinPaths($stow, $file),
&JoinPaths($Target, $subfile)); &JoinPaths($Target, $subfile));
@ -488,16 +488,16 @@ sub DoMkdir {
} }
sub Conflict { sub Conflict {
local($a, $b) = @_; local($a, $b, $type) = @_;
my $src = &JoinPaths($Stow, $a); my $src = &JoinPaths($Stow, $a);
my $dst = &JoinPaths($Target, $b); my $dst = &JoinPaths($Target, $b);
if ($Conflicts) { if ($Conflicts) {
warn "CONFLICT: $src vs. $dst\n"; warn "CONFLICT: $src vs. $dst", ($type ? " ($type)" : ''), "\n";
#system "ls -l $src $dst"; #system "ls -l $src $dst";
} else { } else {
die "$ProgramName: CONFLICT: $src vs. $dst\n"; die "$ProgramName: CONFLICT: $src vs. $dst", ($type ? " ($type)" : ''), "\n";
} }
} }