1 package hudson.scm; 2 3 import hudson.model.AbstractBuild; 4 import hudson.model.User; 5 import hudson.scm.SubversionChangeLogSet.LogEntry; 6 7 import java.io.IOException ; 8 import java.util.ArrayList ; 9 import java.util.Collections ; 10 import java.util.Iterator ; 11 import java.util.List ; 12 import java.util.Map ; 13 import java.util.Collection ; 14 import java.util.AbstractList ; 15 16 21 public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> { 22 private final List <LogEntry> logs; 23 24 27 private Map <String ,Long > revisionMap; 28 29 SubversionChangeLogSet(AbstractBuild build, List <LogEntry> logs) { 30 super(build); 31 this.logs = Collections.unmodifiableList(logs); 32 for (LogEntry log : logs) 33 log.setParent(this); 34 } 35 36 public boolean isEmptySet() { 37 return logs.isEmpty(); 38 } 39 40 public List <LogEntry> getLogs() { 41 return logs; 42 } 43 44 45 public Iterator <LogEntry> iterator() { 46 return logs.iterator(); 47 } 48 49 public synchronized Map <String ,Long > getRevisionMap() throws IOException { 50 if(revisionMap==null) 51 revisionMap = SubversionSCM.parseRevisionFile(build); 52 return revisionMap; 53 } 54 55 58 public static class LogEntry extends ChangeLogSet.Entry { 59 private int revision; 60 private User author; 61 private String date; 62 private String msg; 63 private List <Path> paths = new ArrayList <Path>(); 64 65 public int getRevision() { 66 return revision; 67 } 68 69 public void setRevision(int revision) { 70 this.revision = revision; 71 } 72 73 public User getAuthor() { 74 return author; 75 } 76 77 public Collection <String > getAffectedPaths() { 78 return new AbstractList <String >() { 79 public String get(int index) { 80 return paths.get(index).value; 81 } 82 public int size() { 83 return paths.size(); 84 } 85 }; 86 } 87 88 public void setUser(String author) { 89 this.author = User.get(author); 90 } 91 92 public String getUser() { return author.getDisplayName(); 94 } 95 96 public String getDate() { 97 return date; 98 } 99 100 public void setDate(String date) { 101 this.date = date; 102 } 103 104 public String getMsg() { 105 return msg; 106 } 107 108 public void setMsg(String msg) { 109 this.msg = msg; 110 } 111 112 public void addPath( Path p ) { 113 paths.add(p); 114 } 115 116 public List <Path> getPaths() { 117 return paths; 118 } 119 } 120 121 public static class Path { 122 private char action; 123 private String value; 124 125 public void setAction(String action) { 126 this.action = action.charAt(0); 127 } 128 129 public String getValue() { 130 return value; 131 } 132 133 public void setValue(String value) { 134 this.value = value; 135 } 136 137 public EditType getEditType() { 138 if( action=='A' ) 139 return EditType.ADD; 140 if( action=='D' ) 141 return EditType.DELETE; 142 return EditType.EDIT; 143 } 144 } 145 } 146 | Popular Tags |