3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 # Free Software Foundation, Inc.
6 # This file is part of GNU Emacs.
8 # GNU Emacs is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # GNU Emacs is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29 Get a diff of FILE between revisions OLD and NEW. Store the
30 diff in a file named FILE-OLD-NEW.diff.
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.
35 If NEW is +<number> or -<number>, build diffs between revisions OLD
40 revdiff FILE - -1 get the latest change of FILE
41 revdiff FILE -1 +1 also gets the latest change of FILE
42 revdiff FILE 1.500 +2 get diffs 1.500-1.501 and 1.501-1.502.
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";
58 sub current_revision
($)
61 my $dir = dirname
($file);
62 my $base = basename
($file);
63 my $entries = "$dir/CVS/Entries";
64 die "Can't find $entries" unless -f
$entries;
65 open (IN
, "<$entries") or die "Cannot open $entries";
69 if ($line =~ m
,/$base/([^/]+),)
75 die "Cannot determine current revision of $file" unless $rev;
82 $old = current_revision
($file);
84 elsif ($old =~ /^-(\d+)$/)
87 $old = current_revision
($file);
88 die "Internal error" unless $old =~ /(.*)\.(\d+)$/;
89 my $minor = $2 - $offset;
90 $old = sprintf ("%d.%d", $1, $minor);
95 my $new = shift @ARGV;
96 if ($new =~ /^[+]\d+$/)
99 for ($i = 0; $i < $n; ++$i)
101 unless ($old =~ /(.*)\.(\d+)$/)
103 die "Internal error";
111 elsif ($new =~ /^[-]\d+$/)
114 for ($i = 0; $i < $n; ++$i)
116 unless ($old =~ /(.*)\.(\d+)$/)
118 die "Internal error";
137 # arch-tag: 2798b20d-c7f2-4c78-8378-7bb529c36a09