Mercurial > emacs
comparison admin/revdiff @ 49600:23a1cea22d13
Trailing whitespace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 14:56:31 +0000 |
parents | 570be39418f4 |
children | 695cf19ef79e d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49599:5ade352e8d1c | 49600:23a1cea22d13 |
---|---|
19 # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 # Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 # Boston, MA 02111-1307, USA. | 20 # Boston, MA 02111-1307, USA. |
21 | 21 |
22 use File::Basename; | 22 use File::Basename; |
23 | 23 |
24 if (@ARGV < 3) | 24 if (@ARGV < 3) |
25 { | 25 { |
26 print <<USAGE; | 26 print <<USAGE; |
27 revdiff FILE OLD NEW | 27 revdiff FILE OLD NEW |
28 | 28 |
29 Get a diff of FILE between revisions OLD and NEW. Store the | 29 Get a diff of FILE between revisions OLD and NEW. Store the |
30 diff in a file named FILE-OLD-NEW.diff. | 30 diff in a file named FILE-OLD-NEW.diff. |
31 | 31 |
32 If OLD is `-' use FILE's current revision for OLD. If OLD is | 32 If OLD is `-' use FILE's current revision for OLD. If OLD is |
33 `-<number>', use the Nth revision before the current one for OLD. | 33 `-<number>', use the Nth revision before the current one for OLD. |
46 } | 46 } |
47 | 47 |
48 $file = shift @ARGV; | 48 $file = shift @ARGV; |
49 $old = shift @ARGV; | 49 $old = shift @ARGV; |
50 | 50 |
51 sub diffit | 51 sub diffit |
52 { | 52 { |
53 my ($old, $new) = @_; | 53 my ($old, $new) = @_; |
54 print "cvs diff -r$old -r$new $file >$file-$old-$new.diff\n"; | 54 print "cvs diff -r$old -r$new $file >$file-$old-$new.diff\n"; |
55 system "cvs diff -r$old -r$new $file >$file-$old-$new.diff"; | 55 system "cvs diff -r$old -r$new $file >$file-$old-$new.diff"; |
56 } | 56 } |
62 my $base = basename ($file); | 62 my $base = basename ($file); |
63 my $entries = "$dir/CVS/Entries"; | 63 my $entries = "$dir/CVS/Entries"; |
64 die "Can't find $entries" unless -f $entries; | 64 die "Can't find $entries" unless -f $entries; |
65 open (IN, "<$entries") or die "Cannot open $entries"; | 65 open (IN, "<$entries") or die "Cannot open $entries"; |
66 my $rev; | 66 my $rev; |
67 while ($line = <IN>) | 67 while ($line = <IN>) |
68 { | 68 { |
69 if ($line =~ m,/$base/([^/]+),) | 69 if ($line =~ m,/$base/([^/]+),) |
70 { | 70 { |
71 $rev = $1; | 71 $rev = $1; |
72 break; | 72 break; |
73 } | 73 } |
74 } | 74 } |
79 | 79 |
80 if ($old eq "-") | 80 if ($old eq "-") |
81 { | 81 { |
82 $old = current_revision ($file); | 82 $old = current_revision ($file); |
83 } | 83 } |
84 elsif ($old =~ /^-(\d+)$/) | 84 elsif ($old =~ /^-(\d+)$/) |
85 { | 85 { |
86 my $offset = $1; | 86 my $offset = $1; |
87 $old = current_revision ($file); | 87 $old = current_revision ($file); |
88 die "Internal error" unless $old =~ /(.*)\.(\d+)$/; | 88 die "Internal error" unless $old =~ /(.*)\.(\d+)$/; |
89 my $minor = $2 - $offset; | 89 my $minor = $2 - $offset; |
90 $old = sprintf ("%d.%d", $1, $minor); | 90 $old = sprintf ("%d.%d", $1, $minor); |
91 } | 91 } |
92 | 92 |
93 while (@ARGV) | 93 while (@ARGV) |
94 { | 94 { |
95 my $new = shift @ARGV; | 95 my $new = shift @ARGV; |
96 if ($new =~ /^[+]\d+$/) | 96 if ($new =~ /^[+]\d+$/) |
97 { | 97 { |
98 my $n = $new; | 98 my $n = $new; |
99 for ($i = 0; $i < $n; ++$i) | 99 for ($i = 0; $i < $n; ++$i) |
100 { | 100 { |
101 unless ($old =~ /(.*)\.(\d+)$/) | 101 unless ($old =~ /(.*)\.(\d+)$/) |
102 { | 102 { |
103 die "Internal error"; | 103 die "Internal error"; |
104 } | 104 } |
105 my $j = $2 + 1; | 105 my $j = $2 + 1; |
106 $new = "$1.$j"; | 106 $new = "$1.$j"; |
107 diffit ($old, $new); | 107 diffit ($old, $new); |
108 $old = $new; | 108 $old = $new; |
109 } | 109 } |
110 } | 110 } |
111 elsif ($new =~ /^[-]\d+$/) | 111 elsif ($new =~ /^[-]\d+$/) |
112 { | 112 { |
113 my $n = - $new; | 113 my $n = - $new; |
114 for ($i = 0; $i < $n; ++$i) | 114 for ($i = 0; $i < $n; ++$i) |
115 { | 115 { |
116 unless ($old =~ /(.*)\.(\d+)$/) | 116 unless ($old =~ /(.*)\.(\d+)$/) |
117 { | 117 { |
118 die "Internal error"; | 118 die "Internal error"; |
119 } | 119 } |
120 my $j = $2 - 1; | 120 my $j = $2 - 1; |
121 $new = "$1.$j"; | 121 $new = "$1.$j"; |
122 diffit ($new, $old); | 122 diffit ($new, $old); |
123 $old = $new; | 123 $old = $new; |
124 } | 124 } |
125 } | 125 } |
126 else | 126 else |
127 { | 127 { |
128 diffit ($old, $new); | 128 diffit ($old, $new); |
129 $old = $new; | 129 $old = $new; |
130 } | 130 } |
131 } | 131 } |