annotate admin/revdiff @ 47051:11f467f2a131

(kmacro-start-macro): Doc fix.
author Andreas Schwab <schwab@suse.de>
date Tue, 27 Aug 2002 15:05:44 +0000
parents 570be39418f4
children 23a1cea22d13
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38850
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 #! /usr/bin/perl
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 # Copyright (C) 2001 Free Software Foundation, Inc.
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4 #
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 # This file is part of GNU Emacs.
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 #
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 # GNU Emacs is free software; you can redistribute it and/or modify
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 # it under the terms of the GNU General Public License as published by
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 # the Free Software Foundation; either version 2, or (at your option)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 # any later version.
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 #
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 # GNU Emacs is distributed in the hope that it will be useful,
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 # GNU General Public License for more details.
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 #
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 # You should have received a copy of the GNU General Public License
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 # along with GNU Emacs; see the file COPYING. If not, write to the
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 # Boston, MA 02111-1307, USA.
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 use File::Basename;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 if (@ARGV < 3)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 print <<USAGE;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 revdiff FILE OLD NEW
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 Get a diff of FILE between revisions OLD and NEW. Store the
39132
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
30 diff in a file named FILE-OLD-NEW.diff.
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
31
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
32 If OLD is `-' use FILE's current revision for OLD. If OLD is
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
33 `-<number>', use the Nth revision before the current one for OLD.
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
34
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
35 If NEW is +<number> or -<number>, build diffs between revisions OLD
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
36 and OLD +/- <number>.
38850
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 Examples:
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 revdiff FILE - -1 get the latest change of FILE
39132
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
41 revdiff FILE -1 +1 also gets the latest change of FILE
38850
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 revdiff FILE 1.500 +2 get diffs 1.500-1.501 and 1.501-1.502.
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 USAGE
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 exit 1;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 $file = shift @ARGV;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 $old = shift @ARGV;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 sub diffit
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 my ($old, $new) = @_;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 print "cvs diff -r$old -r$new $file >$file-$old-$new.diff\n";
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 system "cvs diff -r$old -r$new $file >$file-$old-$new.diff";
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 sub current_revision ($)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 my ($file) = @_;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 my $dir = dirname ($file);
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 my $base = basename ($file);
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 my $entries = "$dir/CVS/Entries";
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 die "Can't find $entries" unless -f $entries;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 open (IN, "<$entries") or die "Cannot open $entries";
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 my $rev;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 while ($line = <IN>)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 if ($line =~ m,/$base/([^/]+),)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 $rev = $1;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 break;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 die "Cannot determine current revision of $file" unless $rev;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 close (IN);
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 return $rev;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 if ($old eq "-")
39132
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
81 {
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
82 $old = current_revision ($file);
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
83 }
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
84 elsif ($old =~ /^-(\d+)$/)
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
85 {
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
86 my $offset = $1;
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
87 $old = current_revision ($file);
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
88 die "Internal error" unless $old =~ /(.*)\.(\d+)$/;
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
89 my $minor = $2 - $offset;
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
90 $old = sprintf ("%d.%d", $1, $minor);
570be39418f4 Allow -<number> for OLD.
Gerd Moellmann <gerd@gnu.org>
parents: 38850
diff changeset
91 }
38850
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 while (@ARGV)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 my $new = shift @ARGV;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 if ($new =~ /^[+]\d+$/)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 my $n = $new;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 for ($i = 0; $i < $n; ++$i)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 unless ($old =~ /(.*)\.(\d+)$/)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 die "Internal error";
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 my $j = $2 + 1;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 $new = "$1.$j";
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 diffit ($old, $new);
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 $old = $new;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 elsif ($new =~ /^[-]\d+$/)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 my $n = - $new;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 for ($i = 0; $i < $n; ++$i)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 unless ($old =~ /(.*)\.(\d+)$/)
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 die "Internal error";
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 my $j = $2 - 1;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 $new = "$1.$j";
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 diffit ($new, $old);
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 $old = $new;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 else
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 {
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 diffit ($old, $new);
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 $old = $new;
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 }
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 # Local Variables:
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 # mode: cperl
f87dbbd87498 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 # End: