Source Code Cross Referenced for SVNCommandEventProcessor.java in  » Source-Control » tmatesoft-SVN » org » tmatesoft » svn » cli » command » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Source Control » tmatesoft SVN » org.tmatesoft.svn.cli.command 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ====================================================================
003:         * Copyright (c) 2004-2008 TMate Software Ltd.  All rights reserved.
004:         *
005:         * This software is licensed as described in the file COPYING, which
006:         * you should have received as part of this distribution.  The terms
007:         * are also available at http://svnkit.com/license.html
008:         * If newer versions of this license are posted there, you may use a
009:         * newer version instead, at your option.
010:         * ====================================================================
011:         */
012:        package org.tmatesoft.svn.cli.command;
013:
014:        import java.io.File;
015:        import java.io.IOException;
016:        import java.io.PrintStream;
017:
018:        import org.tmatesoft.svn.cli.SVNCommand;
019:        import org.tmatesoft.svn.core.SVNCancelException;
020:        import org.tmatesoft.svn.core.SVNLock;
021:        import org.tmatesoft.svn.core.SVNNodeKind;
022:        import org.tmatesoft.svn.core.SVNProperty;
023:        import org.tmatesoft.svn.core.internal.util.SVNFormatUtil;
024:        import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
025:        import org.tmatesoft.svn.core.wc.ISVNEventHandler;
026:        import org.tmatesoft.svn.core.wc.SVNEvent;
027:        import org.tmatesoft.svn.core.wc.SVNEventAction;
028:        import org.tmatesoft.svn.core.wc.SVNStatusType;
029:
030:        /**
031:         * @version 1.1.1
032:         * @author  TMate Software Ltd.
033:         */
034:        public class SVNCommandEventProcessor implements  ISVNEventHandler {
035:
036:            private boolean myIsExternal;
037:            private boolean myIsChanged;
038:            private boolean myIsExternalChanged;
039:            private boolean myIsCheckout;
040:            private boolean myIsExport;
041:            private boolean myIsDelta;
042:
043:            private final PrintStream myPrintStream;
044:            private PrintStream myErrStream;
045:
046:            public SVNCommandEventProcessor(PrintStream out, PrintStream err,
047:                    boolean checkout) {
048:                this (out, err, checkout, false);
049:            }
050:
051:            public SVNCommandEventProcessor(PrintStream out, PrintStream err,
052:                    boolean checkout, boolean export) {
053:                myPrintStream = out;
054:                myErrStream = err;
055:                myIsCheckout = checkout;
056:                myIsExport = export;
057:            }
058:
059:            public void handleEvent(SVNEvent event, double progress) {
060:                String commitPath = null;
061:                if (event.getAction() == SVNEventAction.COMMIT_ADDED
062:                        || event.getAction() == SVNEventAction.COMMIT_MODIFIED
063:                        || event.getAction() == SVNEventAction.COMMIT_DELETED
064:                        || event.getAction() == SVNEventAction.COMMIT_REPLACED) {
065:                    File root = new File(".");
066:                    File file = event.getFile();
067:                    try {
068:                        if (root.getCanonicalFile().equals(
069:                                file.getCanonicalFile())
070:                                || SVNPathUtil.isChildOf(root, file)) {
071:                            commitPath = SVNFormatUtil.formatPath(event
072:                                    .getFile());
073:                        } else {
074:                            commitPath = event.getPath();
075:                            if ("".equals(commitPath)) {
076:                                commitPath = ".";
077:                            }
078:                        }
079:                    } catch (IOException e) {
080:                        //
081:                    }
082:                }
083:                if (event.getAction() == SVNEventAction.COMMIT_MODIFIED) {
084:                    SVNCommand.println(myPrintStream, "Sending        "
085:                            + commitPath);
086:                } else if (event.getAction() == SVNEventAction.COMMIT_DELETED) {
087:                    SVNCommand.println(myPrintStream, "Deleting       "
088:                            + commitPath);
089:                } else if (event.getAction() == SVNEventAction.COMMIT_REPLACED) {
090:                    SVNCommand.println(myPrintStream, "Replacing      "
091:                            + commitPath);
092:                } else if (event.getAction() == SVNEventAction.COMMIT_DELTA_SENT) {
093:                    if (!myIsDelta) {
094:                        SVNCommand.print(myPrintStream,
095:                                "Transmitting file data ");
096:                        myIsDelta = true;
097:                    }
098:                    SVNCommand.print(myPrintStream, ".");
099:                } else if (event.getAction() == SVNEventAction.COMMIT_ADDED) {
100:                    String mimeType = event.getMimeType();
101:                    if (SVNProperty.isBinaryMimeType(mimeType)) {
102:                        SVNCommand.println(myPrintStream, "Adding  (bin)  "
103:                                + commitPath);
104:                    } else {
105:                        SVNCommand.println(myPrintStream, "Adding         "
106:                                + commitPath);
107:                    }
108:                } else if (event.getAction() == SVNEventAction.REVERT) {
109:                    SVNCommand.println(myPrintStream, "Reverted '"
110:                            + SVNFormatUtil.formatPath(event.getFile()) + "'");
111:                } else if (event.getAction() == SVNEventAction.FAILED_REVERT) {
112:                    SVNCommand.println(myPrintStream, "Failed to revert '"
113:                            + SVNFormatUtil.formatPath(event.getFile())
114:                            + "' -- try updating instead.");
115:                } else if (event.getAction() == SVNEventAction.LOCKED) {
116:                    String path = event.getPath();
117:                    if (event.getFile() != null) {
118:                        path = SVNFormatUtil.formatPath(event.getFile());
119:                    }
120:                    SVNLock lock = event.getLock();
121:                    SVNCommand.println(myPrintStream, "'" + path
122:                            + "' locked by user '" + lock.getOwner() + "'.");
123:                } else if (event.getAction() == SVNEventAction.UNLOCKED) {
124:                    String path = event.getPath();
125:                    if (event.getFile() != null) {
126:                        path = SVNFormatUtil.formatPath(event.getFile());
127:                    }
128:                    SVNCommand.println(myPrintStream, "'" + path
129:                            + "' unlocked.");
130:                } else if (event.getAction() == SVNEventAction.UNLOCK_FAILED) {
131:                    SVNCommand.println(myErrStream, "error: "
132:                            + event.getErrorMessage());
133:                } else if (event.getAction() == SVNEventAction.LOCK_FAILED) {
134:                    SVNCommand.println(myErrStream, "error: "
135:                            + event.getErrorMessage());
136:                } else if (event.getAction() == SVNEventAction.UPDATE_ADD) {
137:                    if (myIsExternal) {
138:                        myIsExternalChanged = true;
139:                    } else {
140:                        myIsChanged = true;
141:                    }
142:                    if (event.getContentsStatus() == SVNStatusType.CONFLICTED) {
143:                        SVNCommand.println(myPrintStream, "C    "
144:                                + SVNFormatUtil.formatPath(event.getFile()));
145:                    } else {
146:                        SVNCommand.println(myPrintStream, "A    "
147:                                + SVNFormatUtil.formatPath(event.getFile()));
148:                    }
149:                } else if (event.getAction() == SVNEventAction.UPDATE_DELETE) {
150:                    if (myIsExternal) {
151:                        myIsExternalChanged = true;
152:                    } else {
153:                        myIsChanged = true;
154:                    }
155:                    SVNCommand.println(myPrintStream, "D    "
156:                            + SVNFormatUtil.formatPath(event.getFile()));
157:                } else if (event.getAction() == SVNEventAction.UPDATE_UPDATE) {
158:                    StringBuffer sb = new StringBuffer();
159:                    if (event.getNodeKind() != SVNNodeKind.DIR) {
160:                        if (event.getContentsStatus() == SVNStatusType.CHANGED) {
161:                            sb.append("U");
162:                        } else if (event.getContentsStatus() == SVNStatusType.CONFLICTED) {
163:                            sb.append("C");
164:                        } else if (event.getContentsStatus() == SVNStatusType.MERGED) {
165:                            sb.append("G");
166:                        } else {
167:                            sb.append(" ");
168:                        }
169:                    } else {
170:                        sb.append(' ');
171:                    }
172:                    if (event.getPropertiesStatus() == SVNStatusType.CHANGED) {
173:                        sb.append("U");
174:                    } else if (event.getPropertiesStatus() == SVNStatusType.CONFLICTED) {
175:                        sb.append("C");
176:                    } else if (event.getPropertiesStatus() == SVNStatusType.MERGED) {
177:                        sb.append("G");
178:                    } else {
179:                        sb.append(" ");
180:                    }
181:                    if (sb.toString().trim().length() != 0) {
182:                        if (myIsExternal) {
183:                            myIsExternalChanged = true;
184:                        } else {
185:                            myIsChanged = true;
186:                        }
187:                    }
188:                    if (event.getLockStatus() == SVNStatusType.LOCK_UNLOCKED) {
189:                        sb.append("B");
190:                    } else {
191:                        sb.append(" ");
192:                    }
193:                    if (sb.toString().trim().length() > 0) {
194:                        SVNCommand.println(myPrintStream, sb.toString() + "  "
195:                                + SVNFormatUtil.formatPath(event.getFile()));
196:                    }
197:                } else if (event.getAction() == SVNEventAction.UPDATE_COMPLETED) {
198:                    if (!myIsExternal) {
199:                        if (myIsChanged) {
200:                            if (myIsCheckout) {
201:                                SVNCommand.println(myPrintStream,
202:                                        "Checked out revision "
203:                                                + event.getRevision() + ".");
204:                            } else if (myIsExport) {
205:                                SVNCommand.println(myPrintStream,
206:                                        "Export complete.");
207:                            } else {
208:                                SVNCommand.println(myPrintStream,
209:                                        "Updated to revision "
210:                                                + event.getRevision() + ".");
211:                            }
212:                        } else {
213:                            if (myIsCheckout) {
214:                                SVNCommand.println(myPrintStream,
215:                                        "Checked out revision "
216:                                                + event.getRevision() + ".");
217:                            } else if (myIsExport) {
218:                                SVNCommand.println(myPrintStream,
219:                                        "Export complete.");
220:                            } else {
221:                                SVNCommand.println(myPrintStream,
222:                                        "At revision " + event.getRevision()
223:                                                + ".");
224:                            }
225:                        }
226:                    } else {
227:                        if (myIsExternalChanged) {
228:                            if (myIsCheckout) {
229:                                SVNCommand.println(myPrintStream,
230:                                        "Checked out external at revision "
231:                                                + event.getRevision() + ".");
232:                            } else if (myIsExport) {
233:                                SVNCommand.println(myPrintStream,
234:                                        "Export complete.");
235:                            } else {
236:                                SVNCommand.println(myPrintStream,
237:                                        "Updated external to revision "
238:                                                + event.getRevision() + ".");
239:                            }
240:                        } else {
241:                            SVNCommand.println(myPrintStream,
242:                                    "External at revision "
243:                                            + event.getRevision() + ".");
244:                        }
245:                        SVNCommand.println(myPrintStream);
246:                        myIsExternalChanged = false;
247:                        myIsExternal = false;
248:                    }
249:                } else if (event.getAction() == SVNEventAction.UPDATE_EXTERNAL) {
250:                    SVNCommand.println(myPrintStream);
251:                    String path = event.getPath().replace('/',
252:                            File.separatorChar);
253:                    if (myIsCheckout) {
254:                        SVNCommand.println(myPrintStream,
255:                                "Fetching external item into '" + path + "'");
256:                    } else {
257:                        SVNCommand.println(myPrintStream,
258:                                "Updating external item at '" + path + "'");
259:                    }
260:                    myIsExternal = true;
261:                } else if (event.getAction() == SVNEventAction.STATUS_EXTERNAL) {
262:                    SVNCommand.println(myPrintStream);
263:                    String path = event.getPath().replace('/',
264:                            File.separatorChar);
265:                    SVNCommand.println(myPrintStream,
266:                            "Performing status on external item at '" + path
267:                                    + "'");
268:                    myIsExternal = true;
269:                } else if (event.getAction() == SVNEventAction.RESTORE) {
270:                    SVNCommand.println(myPrintStream, "Restored '"
271:                            + SVNFormatUtil.formatPath(event.getFile()) + "'");
272:                } else if (event.getAction() == SVNEventAction.ADD) {
273:                    if (SVNProperty.isBinaryMimeType(event.getMimeType())) {
274:                        SVNCommand.println(myPrintStream, "A  (bin)  "
275:                                + SVNFormatUtil.formatPath(event.getFile()));
276:                    } else {
277:                        SVNCommand.println(myPrintStream, "A         "
278:                                + SVNFormatUtil.formatPath(event.getFile()));
279:                    }
280:                } else if (event.getAction() == SVNEventAction.DELETE) {
281:                    SVNCommand.println(myPrintStream, "D         "
282:                            + SVNFormatUtil.formatPath(event.getFile()));
283:                } else if (event.getAction() == SVNEventAction.SKIP) {
284:                    SVNCommand.println(myPrintStream, "Skipped '"
285:                            + SVNFormatUtil.formatPath(event.getFile()) + "'");
286:                    if (myIsExternal
287:                            && event.getExpectedAction() == SVNEventAction.UPDATE_EXTERNAL) {
288:                        myIsExternal = false;
289:                        myIsExternalChanged = false;
290:                    }
291:                } else if (event.getAction() == SVNEventAction.RESOLVED) {
292:                    SVNCommand.println(myPrintStream,
293:                            "Resolved conflicted state of '"
294:                                    + SVNFormatUtil.formatPath(event.getFile())
295:                                    + "'");
296:                } else if (event.getAction() == SVNEventAction.STATUS_COMPLETED) {
297:                    SVNCommand.println(myPrintStream,
298:                            "Status against revision: "
299:                                    + SVNFormatUtil.formatString(Long
300:                                            .toString(event.getRevision()), 6,
301:                                            false));
302:                }
303:            }
304:
305:            public void checkCancelled() throws SVNCancelException {
306:            }
307:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.