Has anyone created logic to parse and use the output of iwcmp. I'm looking for results similar to that which is shown in the TS GUI when doing a compare too. e.g1). Newer in area 12). Newer in area2 3). Conflicts.
$row =~ /^(\S+)\s(\S+)\s(\S+).*$/;my $targstats = $1;my $sourcestats = $2;my $file = $3;# Changes in sourceif($targstats =~ /^-$/) {push(@sourceChanged, "$row");}if(($targstats !~ /\+/) && ($sourcestats =~ /\+/)) {push(@sourceChanged, "$row");}# Changes in targetif($sourcestats =~ /^-$/) {push(@targetChanged, "$row");}if(($sourcestats !~ /\+/) && ($targstats =~ /\+/)) {push(@targetChanged, "$row");}# Conflictsif(($targstats =~ /\+/) && ($sourcestats =~ /\+/)) {push(@conflicts, "$row");}Can someone verify this logic? I've run into an issue where the total number of differences does not match the total number in each list combined. newer in source + newer in target + conflicts is not equal the total number of differences. I cant sopt the trouble.
chomp($row); # remove newline - unless already done?$row =~ /^(\S+)\s+(\S+)\s+(.*)$/;my $Astat = $1;my $Bstat = $2;my $file = $3; # unused - do you want to push this instead of $row?if ($Astat eq $Bstat){ # file modified in both areas (should only occur with f+ f+) push(@conflicts, $row);}elsif ($Bstat eq "-") { # new file or directory in A push(@Anew, $row);}elsif ($Astat eq "-") { # new file or directory in B push(@Bnew, $row);}elsif ($Astat eq "x+") { # file or directory deleted in A push(@Adel, $row);}elsif ($Bstat eq "x+") { # file or directory deleted in B push(@Bdel, $row);}elsif ($Astat =~ /\+/) { # file or directory modified in A push(@Amod, $row);}elsif ($Bstat =~ /\+/) { # file or directory modified in B push(@Bmod, $row);}else { # unhandled case push(@unknown, $row);}
I think you have source and target stats reversed - though it may depend on the parameters you are passing - instead of thinking "source" and "target" - think "A" and "B" and it might be a bit clearer.chomp($row); # remove newline - unless already done?$row =~ /^(\S+)\s+(\S+)\s+(.*)$/;my $Astat = $1;my $Bstat = $2;my $file = $3; # unused - do you want to push this instead of $row?if ($Astat eq $Bstat){ # file modified in both areas (should only occur with f+ f+) push(@conflicts, $row);}elsif ($Bstat eq "-") { # new file or directory in A push(@Anew, $row);}elsif ($Astat eq "-") { # new file or directory in B push(@Bnew, $row);}elsif ($Astat eq "x+") { # file or directory deleted in A push(@Adel, $row);}elsif ($Bstat eq "x+") { # file or directory deleted in B push(@Bdel, $row);}elsif ($Astat =~ /\+/) { # file or directory modified in A push(@Amod, $row);}elsif ($Bstat =~ /\+/) { # file or directory modified in B push(@Bmod, $row);}else { # unhandled case push(@unknown, $row);}Depending on what you want to do with this information, the level at which you parse the information could be condensed or expanded (i.e. do you care about entries being files vs. directories? do you care about files or directories being marked private or public?)Your numbers were probably not coming out right because you were using just 'if's and not 'elsif's - so the same line was being parsed multiple times.