equal
deleted
inserted
replaced
|
1 #!\usr\bin\perl |
|
2 # Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # Treates the output of diff -q to list common parts of filenames of differing |
|
16 # files |
|
17 # |
|
18 # |
|
19 |
|
20 while (my $line=<STDIN>) |
|
21 { |
|
22 chomp($line); |
|
23 |
|
24 if ($line =~ /^Files .* differ$/) |
|
25 { |
|
26 if ($line =~ /^Files ([^\s]+) and ([^\s]+) differ$/) |
|
27 { |
|
28 # Files present but differing |
|
29 my @one = reverse(split(/[\/\\]/,$1)); |
|
30 my @two = reverse(split(/[\/\\]/,$2)); |
|
31 my @common; # Shared RHS of path/filename |
|
32 |
|
33 my $index = 0; |
|
34 |
|
35 while |
|
36 ( ($index < scalar(@one)) |
|
37 && ($index < scalar(@two)) |
|
38 ) |
|
39 { |
|
40 # If path section is identical, copy to @common |
|
41 if ($one[$index] eq $two[$index]) |
|
42 { unshift @common, $one[$index]; } |
|
43 else |
|
44 { last; } |
|
45 $index++; |
|
46 } |
|
47 |
|
48 print join("\\",@common)."\n"; |
|
49 } |
|
50 else |
|
51 { |
|
52 die "Could not parse \"$line\"\n"; |
|
53 } |
|
54 } |
|
55 } |