1 |
Author: idl0r |
2 |
Date: 2009-06-03 18:34:58 +0000 (Wed, 03 Jun 2009) |
3 |
New Revision: 657 |
4 |
|
5 |
Modified: |
6 |
trunk/gentoolkit-dev/src/echangelog/echangelog |
7 |
Log: |
8 |
Add support for bzr. Cleanup. Removed git related if statement in check for unknown/untracked files since it was useless. |
9 |
|
10 |
Modified: trunk/gentoolkit-dev/src/echangelog/echangelog |
11 |
=================================================================== |
12 |
--- trunk/gentoolkit-dev/src/echangelog/echangelog 2009-05-27 18:44:43 UTC (rev 656) |
13 |
+++ trunk/gentoolkit-dev/src/echangelog/echangelog 2009-06-03 18:34:58 UTC (rev 657) |
14 |
@@ -31,6 +31,14 @@ |
15 |
$opt_version = 0; |
16 |
|
17 |
my %vcs = ( |
18 |
+ bzr => { |
19 |
+ diff => "bzr diff", |
20 |
+ status => "bzr status -S .", |
21 |
+ add => "bzr add", |
22 |
+ skip => 3, |
23 |
+ # The same as for hg. |
24 |
+ regex => qr/^=== \S+ file '\S+\/\S+\/((\S+)\.ebuild)/ |
25 |
+ }, |
26 |
cvs => { |
27 |
diff => "cvs -f diff -U0", |
28 |
status => "cvs -fn up", |
29 |
@@ -38,13 +46,6 @@ |
30 |
skip => 6, |
31 |
regex => qr/^Index: (([^\/]*?)\.ebuild)\s*$/ |
32 |
}, |
33 |
- svn => { |
34 |
- diff => "svn diff -N", |
35 |
- status => "svn status", |
36 |
- add => "svn add", |
37 |
- skip => 4, |
38 |
- regex => qr/^Index: (([^\/]*?)\.ebuild)\s*$/ |
39 |
- }, |
40 |
git => { |
41 |
diff => "git diff", |
42 |
status => "git diff-index HEAD --name-status", |
43 |
@@ -63,6 +64,13 @@ |
44 |
# TODO: Write a proper regex :) |
45 |
regex => qr/diff \-r \S+ \S+\/\S+\/((\S+)\.ebuild)/ |
46 |
}, |
47 |
+ svn => { |
48 |
+ diff => "svn diff -N", |
49 |
+ status => "svn status", |
50 |
+ add => "svn add", |
51 |
+ skip => 4, |
52 |
+ regex => qr/^Index: (([^\/]*?)\.ebuild)\s*$/ |
53 |
+ }, |
54 |
); |
55 |
|
56 |
sub usage { |
57 |
@@ -185,6 +193,7 @@ |
58 |
version() if $opt_version; |
59 |
|
60 |
# Figure out what kind of repo we are in. |
61 |
+# TODO: we might also check svn/cvs more strict. |
62 |
if ( -d "CVS" ) { |
63 |
$vcs = "cvs"; |
64 |
} elsif ( -d '.svn' ) { |
65 |
@@ -193,14 +202,20 @@ |
66 |
# Respect $PATH while looking for git |
67 |
if (getenv("PATH")) { |
68 |
foreach my $path ( split(":", getenv("PATH")) ) { |
69 |
+ if ( -X "$path/bzr" ) { |
70 |
+ open(BZR, '-|', "${path}/bzr root 2>/dev/null"); |
71 |
+ $vcs = "bzr" if defined(<BZR>); |
72 |
+ close(BZR); |
73 |
+ last if $vcs; |
74 |
+ } |
75 |
if ( -X "$path/git" ) { |
76 |
- open(GIT, '-|', "git rev-parse --git-dir 2>/dev/null"); |
77 |
+ open(GIT, '-|', "${path}/git rev-parse --git-dir 2>/dev/null"); |
78 |
$vcs = "git" if defined(<GIT>); |
79 |
close(GIT); |
80 |
last if $vcs; |
81 |
} |
82 |
if ( -X "$path/hg" ) { |
83 |
- open(HG, '-|', "hg root 2>/dev/null"); |
84 |
+ open(HG, '-|', "${path}/hg root 2>/dev/null"); |
85 |
$vcs = "hg" if defined(<HG>); |
86 |
close(HG); |
87 |
last if $vcs; |
88 |
@@ -244,39 +259,62 @@ |
89 |
# Figure out what has changed around here |
90 |
open C, $vcs{$vcs}{status}.' 2>&1 |' or die "Can't run ".$vcs{$vcs}{status}.": $!\n"; |
91 |
while (<C>) { |
92 |
- if (/^C\s+(\S+)/) { |
93 |
- if($vcs eq "git") { |
94 |
- my $filename = $2; |
95 |
- $filename =~ /\S*\/(\S*)/; |
96 |
+ # I don't want mess our existing stuff with the horrible bazaar stuff. |
97 |
+ # TODO: add stuff for untracked/conflicting files. |
98 |
+ if ($vcs eq "bzr") { |
99 |
+ # NEW, DELETED, MODIFIED |
100 |
+ if (/^[\s\+\-]([NDM])\s+(.*)/) { |
101 |
+ my ($status, $filename) = ($1, $2); |
102 |
+ # strip category/package/ since everything is relative to the repo root. |
103 |
+ $filename =~ s/^([^\/]+\/){2}//; |
104 |
|
105 |
- if( -d $1 ) { |
106 |
- next; |
107 |
+ # skip empty $filename, e.g. if you add a new package, the first |
108 |
+ # line would be the package directory app-foo/bar/ but thats stripped above. |
109 |
+ next if !$filename; |
110 |
+ # skip directories |
111 |
+ next if -d $filename; |
112 |
+ |
113 |
+ ($actions{$filename} = $status) =~ tr/NDM/+-/d; |
114 |
+ push(@files, $filename); |
115 |
+ next; |
116 |
} |
117 |
+ # RENAMED/MOVED |
118 |
+ elsif (/^R\s+(\S+) => (\S+)/) { |
119 |
+ my ($old, $new) = ($1, $2); |
120 |
+ $old =~ s/^([^\/]+\/){2}//; |
121 |
+ $new =~ s/^([^\/]+\/){2}//; |
122 |
|
123 |
- push @conflicts, $1; |
124 |
+ next if !$old or !$new; |
125 |
+ next if -d $old or -d $new; |
126 |
+ |
127 |
+ $actions{$old} = '-'; |
128 |
+ $actions{$new} = '+'; |
129 |
+ |
130 |
+ push(@files, $old, $new); |
131 |
next; |
132 |
} |
133 |
- |
134 |
- push @conflicts, $1; |
135 |
- next; |
136 |
- } elsif (/^\?\s+(\S+)/) { |
137 |
+ } |
138 |
+ if (/^C\s+(\S+)/) { |
139 |
+ # TODO: The git part here might be unused |
140 |
if($vcs eq "git") { |
141 |
- my $filename = $2; |
142 |
+ my $filename = $1; |
143 |
$filename =~ /\S*\/(\S*)/; |
144 |
|
145 |
- if( -d $1 ) { |
146 |
- next; |
147 |
- } |
148 |
+ next if -d $filename; |
149 |
|
150 |
- push @unknown, $1; |
151 |
+ push @conflicts, $filename; |
152 |
next; |
153 |
- } else { |
154 |
- push @unknown, $1; |
155 |
} |
156 |
|
157 |
- $actions{$1} = '+'; |
158 |
+ push @conflicts, $1; |
159 |
next; |
160 |
- } elsif (/^([ARMD])\s+\+?\s*(\S+)/) { |
161 |
+ } |
162 |
+ elsif (/^\?\s+(\S+)/) { |
163 |
+ push @unknown, $1; |
164 |
+ $actions{$1} = '?'; |
165 |
+ next; |
166 |
+ } |
167 |
+ elsif (/^([ARMD])\s+\+?\s*(\S+)/) { |
168 |
my ($status, $filename) = ($1,$2); |
169 |
|
170 |
if($vcs eq "git") { |
171 |
@@ -457,21 +495,32 @@ |
172 |
# We assume GNU diff output format here. |
173 |
# git format: diff --git a/app-doc/repodoc/metadata.xml b/app-doc/repodoc/metadata.xml |
174 |
elsif (/$vcs{$vcs}{regex}/) { |
175 |
- my $f = $1; |
176 |
+ my ($file, $version) = ($1, $2); |
177 |
|
178 |
if ($vcs eq "git") { |
179 |
- my $version = $2; |
180 |
- |
181 |
while (<C>) { |
182 |
last if /^deleted file mode|^index/; |
183 |
if (/^new file mode/) { |
184 |
- mypush(@files, $f); |
185 |
+ mypush(@files, $file); |
186 |
mypush(@new_versions, $version); |
187 |
last; |
188 |
} |
189 |
} |
190 |
} |
191 |
|
192 |
+ if ($vcs eq "bzr") { |
193 |
+ if (/^=== added file/) { |
194 |
+ mypush(@files, $file); |
195 |
+ mypush(@new_versions, $version); |
196 |
+ last; |
197 |
+ } |
198 |
+ elsif(/^=== renamed file '.+\/([^\/]+\.ebuild)' => '.+\/(([^\/]+)\.ebuild)'/) { |
199 |
+ mypush(@files, $1, $2); |
200 |
+ mypush(@new_versions, $3); |
201 |
+ last; |
202 |
+ } |
203 |
+ } |
204 |
+ |
205 |
# check if more than just copyright date changed. |
206 |
# skip some lines (vcs dependent) |
207 |
foreach(1..$vcs{$vcs}{skip}) { |
208 |
@@ -481,7 +530,7 @@ |
209 |
while (<C>) { |
210 |
last if /^[A-Za-z]/; |
211 |
if (/^[-+](?!# Copyright)/) { |
212 |
- mypush(@files, $f); |
213 |
+ mypush(@files, $file); |
214 |
last; |
215 |
} |
216 |
} |