aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2007-03-21 15:52:59 +0000
committerfuzzyray <fuzzyray@gentoo.org>2007-03-21 15:52:59 +0000
commit0f4c4df1dabb46f041e1c6f41810f28f4dc96cd8 (patch)
tree83d3a1031846e082efcae70bcc1ef1acc40b87ed
parentChange --no-color to --nocolor for consistency within gentoolkit. (Bug #165165) (diff)
downloadgentoolkit-0f4c4df1dabb46f041e1c6f41810f28f4dc96cd8.tar.gz
gentoolkit-0f4c4df1dabb46f041e1c6f41810f28f4dc96cd8.tar.bz2
gentoolkit-0f4c4df1dabb46f041e1c6f41810f28f4dc96cd8.zip
Re-apply subversion patch
svn path=/; revision=362
-rw-r--r--trunk/src/echangelog/echangelog114
1 files changed, 76 insertions, 38 deletions
diff --git a/trunk/src/echangelog/echangelog b/trunk/src/echangelog/echangelog
index 20e31c8..db0c8ec 100644
--- a/trunk/src/echangelog/echangelog
+++ b/trunk/src/echangelog/echangelog
@@ -26,22 +26,18 @@ my %vcs = ( cvs => { diff => "cvs -f -U0 diff",
status => "cvs -fn up",
add => "cvs -f add",
skip => 6,
- entries => "CVS/Entries" },
+ regex => qr/^Index: ()(([^\/]*?)\.ebuild)\s*$/ },
svn => { diff => "svn diff -N",
status => "svn status",
add => "svn add",
- skip => 4,
- entries => ".svn/entries" },
+ skip => 6,
+ regex => qr/^Index: ()(([^\/]*?)\.ebuild)\s*$/ },
git => { diff => "git diff",
- status => "git up",
+ status => "git diff-index HEAD --name-status",
add => "git add",
- skip => 0,
- entries => "wtf" },
- nov => { diff => "",
- status => "",
- add => "",
- skip => 0,
- entries => "wtf" }
+ skip => 4,
+ regex => qr/^diff \-\-git \S*\/((\S*)\.ebuild)/ }
+
);
# Figure out what kind of repo we are in.
@@ -50,11 +46,11 @@ if ( -d "CVS" ) {
$vcs = "cvs";
} elsif ( -d '.svn' ) {
$vcs = "svn";
-} elsif ( -d '.git' ) {
+} elsif ( open GIT, "git rev-parse --git-dir |" ) {
$vcs = "git";
+ close GIT;
} else {
- print STDERR "** NOTE: No CVS, .git, .svn directories found, cannot know modifications\n";
- $vcs = "nov";
+ die "No CVS, .git, .svn directories found, what kind of repo is this?";
}
# Read the current ChangeLog
@@ -65,8 +61,12 @@ if (-f 'ChangeLog') {
} else {
# No ChangeLog here, maybe we should make one...
if (<*.ebuild>) {
- open I, '</usr/portage/skel.ChangeLog'
- or die "Can't open /usr/portage/skel.ChangeLog for input: $!\n";
+ open C, "portageq envvar PORTDIR |" or die "Can't find PORTDIR";
+ my ($new) = <C>;
+ close C;
+ $new =~ s/\s+$//;
+ open I, "< $new/skel.ChangeLog"
+ or die "Can't open $new/skel.ChangeLog for input: $!\n";
{ local $/ = undef; $text = <I>; }
close I;
my ($cwd) = getcwd();
@@ -81,29 +81,57 @@ if (-f 'ChangeLog') {
}
}
+
# Figure out what has changed around here
open C, $vcs{$vcs}{status}.' 2>&1 |' or die "Can't run ".$vcs{$vcs}{status}.": $!\n";
while (<C>) {
- if (/^C\s+\+?\s+(\S+)/) {
- push @conflicts, $1;
+ if (/^C\s+(\S+)/) {
+ if($vcs eq "git") {
+ my $filename = $2;
+ $filename =~ /\S*\/(\S*)/;
+ if( -d $1 ) {
+ next;
+ }
+ push @conflicts, $1;
+ next;
+ }
+ push @conflicts, $1;
next;
- } elsif (/^\?\s+\+?\s+(\S+)/) {
- push @unknown, $1;
+ } elsif (/^\?\s+(\S+)/) {
+ if($vcs eq "git") {
+ my $filename = $2;
+ $filename =~ /\S*\/(\S*)/;
+ if( -d $1 ) {
+ next;
+ }
+ push @unknown, $1;
+ next;
+ } else {
+ push @unknown, $1;
+ }
$actions{$1} = '+';
next;
- } elsif (/^([ARMD])\s+\+?\s+(\S+)/) {
- push @files, $2;
- ($actions{$2} = $1) =~ tr/ARDM/+--/d;
+ } elsif (/^([ARMD])\s+(\S+)/) {
+ my ($status, $filename) = ($1,$2);
+ if($vcs eq "git") {
+ $filename =~ /\S*\/(\S*)/;
+ $filename = $1;
+ }
+ if( -d $filename ) {
+ next;
+ }
+ push @files, $filename;
+ ($actions{$filename} = $status) =~ tr/ARDM/+--/d;
}
}
# Separate out the trivial files for now
@files = grep {
- !/files.digest|Manifest|ChangeLog|^files$|^\.$/ or do { push @trivial, $_; 0; }
+ !/files.digest|Manifest|ChangeLog/ or do { push @trivial, $_; 0; }
} @files;
@unknown = grep {
- !/files.digest|Manifest|ChangeLog|^files$|^\.$/ or do { push @trivial, $_; 0; }
+ !/files.digest|Manifest|ChangeLog/ or do { push @trivial, $_; 0; }
} @unknown;
# Don't allow any conflicts
@@ -120,7 +148,7 @@ EOT
# out above)
if (@unknown) {
print STDERR <<EOT;
-$vcs reports the following unknown files. Please use "cvs add" before
+$vcs reports the following unknown files. Please use "$vcs add" before
running echangelog, or remove the files in question.
EOT
print STDERR map "? $_\n", @unknown;
@@ -213,21 +241,33 @@ sub sortfunc($$) {
# Forget ebuilds that only have changed copyrights, unless that's all
# the changed files we have
-# does not work with svn TODO
-#@ebuilds = grep /\.ebuild$/, @files;
-#@files = grep !/\.ebuild$/, @files;
+
+@ebuilds = grep /\.ebuild$/, @files;
+@files = grep !/\.ebuild$/, @files;
if (@ebuilds) {
- open C, $vcs{$vcs}{diff}.@ebuilds." 2>&1 |" or die "Can't run: ".$vcs{$vcs}{diff}."$!\n";
+ if ($vcs eq "git") {
+ open C, $vcs{$vcs}{diff}." 2>&1 |" or die "Can't run: ".$vcs{$vcs}{diff}."$!\n";
+ } else {
+ open C, $vcs{$vcs}{diff}."@ebuilds 2>&1 |" or die "Can't run: ".$vcs{$vcs}{diff}."$!\n";
+ }
$_ = <C>;
while (defined $_) {
+ # only possible with cvs
if (/^$vcs diff: (([^\/]*?)\.ebuild) was removed/) {
push @files, $1;
}
- elsif (/^Index: (([^\/]*?)\.ebuild)\s*$/) {
- my ($f, $v) = ($1, $2);
+
+ # We assume GNU diff output format here.
+ # git format: diff --git a/app-doc/repodoc/metadata.xml b/app-doc/repodoc/metadata.xml
+ elsif (/$vcs{$vcs}{regex}/) {
+ my ($f) = ($1);
+ # file was removed from git
+ if (/^deleted file mode/) {
+ $_ = <C>; # just eat the line
+ }
# check if more than just copyright date changed.
- # skip some lines
+ # skip some lines (vcs dependent)
foreach(1..$vcs{$vcs}{skip}){
$_ = <C>;
}
@@ -242,7 +282,7 @@ if (@ebuilds) {
# and we have the next line in $_ for processing
next;
}
- elsif (/^$vcs.*?: (([^\/]*?)\.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
}
@@ -395,9 +435,7 @@ 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, $vcs{$vcs}{entries} ) {
- system("$vcs{$vcs}{add} ChangeLog") unless (scalar grep /\/?ChangeLog\/?/, <F>);
-}
+# Add the new changelog to vcs, maybe it already is added, but who cares right?
+system("$vcs{$vcs}{add} ChangeLog 2>&1 >> /dev/null")
# vim:sw=4 ts=8 expandtab