1 12 package hudson.scm; 13 14 import org.tmatesoft.svn.core.SVNCancelException; 15 import org.tmatesoft.svn.core.wc.ISVNEventHandler; 16 import org.tmatesoft.svn.core.wc.SVNEvent; 17 import org.tmatesoft.svn.core.wc.SVNStatusType; 18 import org.tmatesoft.svn.core.wc.SVNEventAction; 19 import hudson.model.TaskListener; 20 21 import java.io.PrintStream ; 22 23 27 final class SubversionUpdateEventHandler implements ISVNEventHandler { 28 29 private final PrintStream out; 30 31 public SubversionUpdateEventHandler(TaskListener listener) { 32 this.out = listener.getLogger(); 33 } 34 35 public void handleEvent(SVNEvent event, double progress) { 36 41 SVNEventAction action = event.getAction(); 42 String pathChangeType = " "; 43 if (action == SVNEventAction.UPDATE_ADD) { 44 47 pathChangeType = "A"; 48 } else if (action == SVNEventAction.UPDATE_DELETE) { 49 52 pathChangeType = "D"; 53 } else if (action == SVNEventAction.UPDATE_UPDATE) { 54 61 SVNStatusType contentsStatus = event.getContentsStatus(); 62 if (contentsStatus == SVNStatusType.CHANGED) { 63 67 pathChangeType = "U"; 68 }else if (contentsStatus == SVNStatusType.CONFLICTED) { 69 74 pathChangeType = "C"; 75 } else if (contentsStatus == SVNStatusType.MERGED) { 76 81 pathChangeType = "G"; 82 } 83 } else if (action == SVNEventAction.UPDATE_EXTERNAL) { 84 85 out.println("Fetching external item into '" 86 + event.getFile().getAbsolutePath() + "'"); 87 out.println("External at revision " + event.getRevision()); 88 return; 89 } else if (action == SVNEventAction.UPDATE_COMPLETED) { 90 93 out.println("At revision " + event.getRevision()); 94 return; 95 } else if (action == SVNEventAction.ADD){ 96 out.println("A " + event.getPath()); 97 return; 98 } else if (action == SVNEventAction.DELETE){ 99 out.println("D " + event.getPath()); 100 return; 101 } else if (action == SVNEventAction.LOCKED){ 102 out.println("L " + event.getPath()); 103 return; 104 } else if (action == SVNEventAction.LOCK_FAILED){ 105 out.println("failed to lock " + event.getPath()); 106 return; 107 } 108 109 113 SVNStatusType propertiesStatus = event.getPropertiesStatus(); 114 117 String propertiesChangeType = " "; 118 if (propertiesStatus == SVNStatusType.CHANGED) { 119 122 propertiesChangeType = "U"; 123 } else if (propertiesStatus == SVNStatusType.CONFLICTED) { 124 127 propertiesChangeType = "C"; 128 } else if (propertiesStatus == SVNStatusType.MERGED) { 129 133 propertiesChangeType = "G"; 134 } 135 136 139 String lockLabel = " "; 140 SVNStatusType lockType = event.getLockStatus(); 141 142 if (lockType == SVNStatusType.LOCK_UNLOCKED) { 143 146 lockLabel = "B"; 147 } 148 149 if(pathChangeType.equals(" ") && propertiesChangeType.equals(" ") && lockLabel.equals(" ") && event.getPath().equals("")) 150 return; 153 154 out.println(pathChangeType 155 + propertiesChangeType 156 + lockLabel 157 + " " 158 + event.getPath()); 159 } 160 161 public void checkCancelled() throws SVNCancelException { 162 if(Thread.currentThread().isInterrupted()) 163 throw new SVNCancelException(); 164 } 165 } | Popular Tags |