You are viewing a plain text version of this content. The canonical link for it is here.
Posted to alexandria-dev@jakarta.apache.org by jm...@apache.org on 2001/04/09 13:57:44 UTC
cvs commit: jakarta-alexandria/src/java/org/apache/alexandria/blame BlameListener.java Blamer.java JavacBlame.java
jmartin 01/04/09 04:57:44
Modified: src/java/org/apache/alexandria/blame BlameListener.java
Blamer.java JavacBlame.java
Log:
Change blamer to ignore echo messages
Added support for geting the revision number for a blame entry
Revision Changes Path
1.4 +18 -9 jakarta-alexandria/src/java/org/apache/alexandria/blame/BlameListener.java
Index: BlameListener.java
===================================================================
RCS file: /home/cvs/jakarta-alexandria/src/java/org/apache/alexandria/blame/BlameListener.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BlameListener.java 2000/12/18 17:59:40 1.3
+++ BlameListener.java 2001/04/09 11:57:42 1.4
@@ -64,7 +64,7 @@
* who made the change which appears to be breaking the build.
* The results are then written out to a blame xml document.
*
- * @version $Id: BlameListener.java,v 1.3 2000/12/18 17:59:40 martinj Exp $
+ * @version $Id: BlameListener.java,v 1.4 2001/04/09 11:57:42 jmartin Exp $
* @author <a href="mailto:jeff.martin@synamic.co.uk">Jeff Martin</a>
*/
public class BlameListener implements BuildListener{
@@ -96,6 +96,7 @@
// Register the blame handlers
handlers.put("javac", new JavacBlame());
+ handlers.put("Javac", new JavacBlame());
handlers.put("default", new DefaultBlame());
}catch(Exception e){
@@ -148,6 +149,7 @@
*/
public final void taskFinished(BuildEvent event){
if(task!=null){
+ java.lang.System.err.println(event);
Build build = createBuild(java.lang.System.getProperty("alexandria.module"), java.lang.System.getProperty("alexandria.tag"), false);
Msg msg = new Msg();
msg.setContent(this.msg.toString());
@@ -156,9 +158,13 @@
msg.setTask(event.getTask().getTaskName());
msg.setLine(handler.getLine());
- msg.setFile(handler.getFile().substring(java.lang.System.getProperty("alexandria.content.dir").length()));
+ if(java.lang.System.getProperty("alexandria.content.dir").length()<handler.getFile().length()){
+ msg.setFile(handler.getFile().substring(java.lang.System.getProperty("alexandria.content.dir").length()));
+ }
Blamer blamer = new Blamer();
- msg.setSuspect(blamer.blame(handler.getFile(), handler.getLine()));
+ blamer.blame(handler.getFile(), handler.getLine());
+ msg.setSuspect(blamer.getSuspect());
+ msg.setRevision(blamer.getRevision());
build.addMsg(msg);
}
task = null;
@@ -171,10 +177,12 @@
*/
public final void messageLogged(BuildEvent event){
if(event.getPriority()==1){
- success=false;
- task = event.getTask();
- msg.append(event.getMessage());
- msg.append("\n");
+ if(!event.getTask().getTaskName().equalsIgnoreCase("echo")){
+ task = event.getTask();
+ success=false;
+ msg.append(event.getMessage());
+ msg.append("\n");
+ }
}
}
@@ -218,9 +226,10 @@
* Returns the blame handler associated with a task
*/
private final BlameHandler getHandler(String task){
- if(handlers.containsKey(task))
+ if(handlers.containsKey(task)){
return (BlameHandler)handlers.get(task);
- else
+ }else {
return (BlameHandler)handlers.get("default");
+ }
}
}
1.2 +22 -8 jakarta-alexandria/src/java/org/apache/alexandria/blame/Blamer.java
Index: Blamer.java
===================================================================
RCS file: /home/cvs/jakarta-alexandria/src/java/org/apache/alexandria/blame/Blamer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Blamer.java 2000/10/03 12:26:09 1.1
+++ Blamer.java 2001/04/09 11:57:43 1.2
@@ -62,7 +62,7 @@
/**
* Retrives the user name of the last person to edit a specific line of code.
*
- * @version $Id: Blamer.java,v 1.1 2000/10/03 12:26:09 martinj Exp $
+ * @version $Id: Blamer.java,v 1.2 2001/04/09 11:57:43 jmartin Exp $
* @author <a href="mailto:jeff.martin@synamic.co.uk">Jeff Martin</a>
*/
@@ -81,6 +81,8 @@
private int lineNo=0;
/** cvs name of suspect */
private String suspect=null;
+ /** revision number */
+ private String revision=null;
/**
@@ -107,9 +109,23 @@
public final void stop(){ }
/**
+ * Return the name of the person who last edited the specified line of code
+ */
+ public final String getSuspect(){
+ return suspect;
+ }
+
+ /**
+ * Return the revision number when the line of code was last changed
+ */
+ public final String getRevision(){
+ return revision;
+ }
+
+ /**
* Execute task
*/
- public final String blame(String file, int line) {
+ public final void blame(String file, int line) {
lineNo = line;
Commandline toExecute = new Commandline();
@@ -128,7 +144,6 @@
}catch(IOException e){
e.printStackTrace();
}
- return suspect;
}
/**
@@ -141,7 +156,7 @@
int count = 0;
while((line=in.readLine())!=null){
if(count++==lineNo){
- suspect = parse(line);
+ parse(line);
break;
}
}
@@ -150,10 +165,9 @@
/**
* Get the suspects name from the current line.
*/
- private final String parse(String line){
+ private final void parse(String line){
StringTokenizer toke = new StringTokenizer(line);
- if(toke.hasMoreTokens())toke.nextToken();
- if(toke.hasMoreTokens())return toke.nextToken().substring(1);
- return "";
+ if(toke.hasMoreTokens())revision = toke.nextToken();
+ if(toke.hasMoreTokens())suspect = toke.nextToken().substring(1);
}
}
1.2 +4 -2 jakarta-alexandria/src/java/org/apache/alexandria/blame/JavacBlame.java
Index: JavacBlame.java
===================================================================
RCS file: /home/cvs/jakarta-alexandria/src/java/org/apache/alexandria/blame/JavacBlame.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JavacBlame.java 2000/10/03 12:26:09 1.1
+++ JavacBlame.java 2001/04/09 11:57:43 1.2
@@ -56,7 +56,7 @@
* Looks at the message output and returns the file name and line number
* of the broken build file.
*
- * @version $Id: JavacBlame.java,v 1.1 2000/10/03 12:26:09 martinj Exp $
+ * @version $Id: JavacBlame.java,v 1.2 2001/04/09 11:57:43 jmartin Exp $
* @author <a href="mailto:jeff.martin@synamic.co.uk">Jeff Martin</a>
*/
public class JavacBlame implements BlameHandler{
@@ -69,7 +69,9 @@
* Pass the error message to the handler.
*/
public void init(String msg){
- String line1 = msg.substring(0,msg.indexOf("\n"));
+ int pos = msg.indexOf("\n");
+ if(pos<0)pos = msg.indexOf(" ");
+ String line1 = msg.substring(0,pos);
int linePos = line1.indexOf(":");
file = msg.substring(0,linePos);
try{
---------------------------------------------------------------------
To unsubscribe, e-mail: alexandria-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: alexandria-dev-help@jakarta.apache.org