aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2007-02-19 18:07:34 +0000
committerfuzzyray <fuzzyray@gentoo.org>2007-02-19 18:07:34 +0000
commit62ddc5fd9836a1adfc0427316104450b7ad0aad0 (patch)
tree94854ed98df4ab705a376bec39c6567da5fad489
parent- update README (diff)
downloadgentoolkit-62ddc5fd9836a1adfc0427316104450b7ad0aad0.tar.gz
gentoolkit-62ddc5fd9836a1adfc0427316104450b7ad0aad0.tar.bz2
gentoolkit-62ddc5fd9836a1adfc0427316104450b7ad0aad0.zip
Update echangelog to support Subversion and git. Bug #136048
svn path=/; revision=348
-rw-r--r--trunk/src/echangelog/echangelog87
1 files changed, 61 insertions, 26 deletions
diff --git a/trunk/src/echangelog/echangelog b/trunk/src/echangelog/echangelog
index 1867ef6..20e31c8 100644
--- a/trunk/src/echangelog/echangelog
+++ b/trunk/src/echangelog/echangelog
@@ -20,7 +20,42 @@ $Text::Wrap::unexpand = 0;
# Global variables
my (@files, @ebuilds, @conflicts, @trivial, @unknown, @new_versions, %actions);
-my ($input, $editor, $entry, $user, $date, $text, $version, $year);
+my ($input, $editor, $entry, $user, $date, $text, $version, $year, $vcs);
+
+my %vcs = ( cvs => { diff => "cvs -f -U0 diff",
+ status => "cvs -fn up",
+ add => "cvs -f add",
+ skip => 6,
+ entries => "CVS/Entries" },
+ svn => { diff => "svn diff -N",
+ status => "svn status",
+ add => "svn add",
+ skip => 4,
+ entries => ".svn/entries" },
+ git => { diff => "git diff",
+ status => "git up",
+ add => "git add",
+ skip => 0,
+ entries => "wtf" },
+ nov => { diff => "",
+ status => "",
+ add => "",
+ skip => 0,
+ entries => "wtf" }
+);
+
+# Figure out what kind of repo we are in.
+
+if ( -d "CVS" ) {
+ $vcs = "cvs";
+} elsif ( -d '.svn' ) {
+ $vcs = "svn";
+} elsif ( -d '.git' ) {
+ $vcs = "git";
+} else {
+ print STDERR "** NOTE: No CVS, .git, .svn directories found, cannot know modifications\n";
+ $vcs = "nov";
+}
# Read the current ChangeLog
if (-f 'ChangeLog') {
@@ -30,8 +65,8 @@ if (-f 'ChangeLog') {
} else {
# No ChangeLog here, maybe we should make one...
if (<*.ebuild>) {
- open I, '<../../skel.ChangeLog'
- or die "Can't open ../../skel.ChangeLog for input: $!\n";
+ open I, '</usr/portage/skel.ChangeLog'
+ or die "Can't open /usr/portage/skel.ChangeLog for input: $!\n";
{ local $/ = undef; $text = <I>; }
close I;
my ($cwd) = getcwd();
@@ -47,33 +82,34 @@ if (-f 'ChangeLog') {
}
# Figure out what has changed around here
-open C, 'cvs -fn up 2>&1 |' or die "Can't run cvs -fn up: $!\n";
+open C, $vcs{$vcs}{status}.' 2>&1 |' or die "Can't run ".$vcs{$vcs}{status}.": $!\n";
while (<C>) {
- if (/^C (\S+)/) {
+ if (/^C\s+\+?\s+(\S+)/) {
push @conflicts, $1;
next;
- } elsif (/^\? (\S+)/) {
+ } elsif (/^\?\s+\+?\s+(\S+)/) {
push @unknown, $1;
$actions{$1} = '+';
next;
- } elsif (/^([ARM]) (\S+)/) {
+ } elsif (/^([ARMD])\s+\+?\s+(\S+)/) {
push @files, $2;
- ($actions{$2} = $1) =~ tr/ARM/+-/d;
+ ($actions{$2} = $1) =~ tr/ARDM/+--/d;
}
}
# Separate out the trivial files for now
@files = grep {
- !/files.digest|Manifest|ChangeLog/ or do { push @trivial, $_; 0; }
+ !/files.digest|Manifest|ChangeLog|^files$|^\.$/ or do { push @trivial, $_; 0; }
} @files;
+
@unknown = grep {
- !/files.digest|Manifest|ChangeLog/ or do { push @trivial, $_; 0; }
+ !/files.digest|Manifest|ChangeLog|^files$|^\.$/ or do { push @trivial, $_; 0; }
} @unknown;
# Don't allow any conflicts
if (@conflicts) {
print STDERR <<EOT;
-Cvs reports the following conflicts. Please resolve them before
+$vcs reports the following conflicts. Please resolve them before
running echangelog.
EOT
print STDERR map "C $_\n", @conflicts;
@@ -84,7 +120,7 @@ EOT
# out above)
if (@unknown) {
print STDERR <<EOT;
-Cvs reports the following unknown files. Please use "cvs add" before
+$vcs reports the following unknown files. Please use "cvs add" before
running echangelog, or remove the files in question.
EOT
print STDERR map "? $_\n", @unknown;
@@ -177,25 +213,24 @@ sub sortfunc($$) {
# Forget ebuilds that only have changed copyrights, unless that's all
# the changed files we have
-@ebuilds = grep /\.ebuild$/, @files;
-@files = grep !/\.ebuild$/, @files;
+# does not work with svn TODO
+#@ebuilds = grep /\.ebuild$/, @files;
+#@files = grep !/\.ebuild$/, @files;
+
if (@ebuilds) {
- open C, "cvs -f diff -U0 @ebuilds 2>&1 |" or die "Can't run cvs diff: $!\n";
+ open C, $vcs{$vcs}{diff}.@ebuilds." 2>&1 |" or die "Can't run: ".$vcs{$vcs}{diff}."$!\n";
$_ = <C>;
while (defined $_) {
- if (/^cvs diff: (([^\/]*?)\.ebuild) was removed/) {
+ if (/^$vcs diff: (([^\/]*?)\.ebuild) was removed/) {
push @files, $1;
}
elsif (/^Index: (([^\/]*?)\.ebuild)\s*$/) {
my ($f, $v) = ($1, $2);
# check if more than just copyright date changed.
# skip some lines
- $_ = <C>; # ====================================
- $_ = <C>; # RCS file: ...
- $_ = <C>; # retrieving revision
- $_ = <C>; # diff -u ...
- $_ = <C>; # --- vim-6.2-r6.ebuild
- $_ = <C>; # +++ vim-6.2-r6.ebuild
+ foreach(1..$vcs{$vcs}{skip}){
+ $_ = <C>;
+ }
while (<C>) {
last if /^[A-Za-z]/;
if (/^[-+](?!# Copyright)/) {
@@ -207,7 +242,7 @@ if (@ebuilds) {
# and we have the next line in $_ for processing
next;
}
- elsif (/^cvs.*?: (([^\/]*?)\.ebuild) is a new entry/) {
+ elsif (/^$vcs.*?: (([^\/]*?)\.ebuild) is a new entry/) {
push @files, $1;
push @new_versions, $2; # new ebuild, will create a new entry
}
@@ -334,7 +369,7 @@ close O or die "Can't close ChangeLog.new: $!\n";
# Update affected ebuild copyright dates. There is no reason to update the
# copyright lines on ebuilds that haven't changed. I verified this with an IP
# lawyer.
-for my $e (grep { /\.ebuild$/ && -e } @files) {
+for my $e (grep /\.ebuild$/, @files) {
my ($etext, $netext);
open E, "<$e" or warn("Can't read $e to update copyright year\n"), next;
{ local $/ = undef; $etext = <E>; }
@@ -361,8 +396,8 @@ rename 'ChangeLog.new', 'ChangeLog' or die "Can't rename ChangeLog.new: $!\n";
# Okay, now we have a starter ChangeLog to work with.
# The text will be added just like with any other ChangeLog below.
# Add the new ChangeLog to cvs before continuing.
-if (open F, "CVS/Entries") {
- system("cvs -f add ChangeLog") unless (scalar grep /^\/ChangeLog\//, <F>);
+if (open F, $vcs{$vcs}{entries} ) {
+ system("$vcs{$vcs}{add} ChangeLog") unless (scalar grep /\/?ChangeLog\/?/, <F>);
}
# vim:sw=4 ts=8 expandtab