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