Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * #Purpose: Check SVN status of project files
- *
- * @author: Kos Ivantsov
- * @date: 2013-07-13
- * @version: 0.1
- *
- */
- import static javax.swing.JOptionPane.*
- import static org.omegat.util.Platform.*
- import org.omegat.core.team.SVNRemoteRepository
- import org.tmatesoft.svn.core.*
- import org.tmatesoft.svn.core.wc.*
- def prop = project.getProjectProperties()
- if (!prop) {
- final def title = 'SVN status'
- final def msg = 'Please try again after you open a project.'
- showMessageDialog null, msg, title, INFORMATION_MESSAGE
- return
- }
- if (project.isProjectLoaded()) {
- def folder = new File(prop.getProjectRoot())
- def projsav = new File(prop.getProjectRoot() + "omegat", "project_save.tmx")
- def glos = new File(prop.writeableGlossary)
- def curfile = new File(prop.getSourceRoot() + editor.getCurrentFile())
- def curfile_svn = 'none'
- if (SVNRemoteRepository.isSVNDirectory(folder)) {
- def clientManager = SVNClientManager.newInstance();
- try {
- folder_status_r = clientManager.getStatusClient().doStatus(folder, true, true);
- } catch (SVNException e) {
- if (e.getErrorMessage().getErrorCode().getCode()==175002) {
- //no connection to host
- console.println "No connection to host"
- final def title = 'SVN status'
- final def msg = 'No connection to host.'
- showMessageDialog null, msg, title, INFORMATION_MESSAGE
- return
- }else throw e
- }
- projsav_status_r = clientManager.getStatusClient().doStatus(projsav, true, true);
- glos_status_r = clientManager.getStatusClient().doStatus(glos, true, true);
- try {
- curfile_status_r = clientManager.getStatusClient().doStatus(curfile, true, true);
- } catch (SVNException e) {
- if (e.getErrorMessage().getErrorCode().getCode()==155007) {
- //file is outside repository, so not under version control.
- curfile_statusType = "not under version control"
- curfile_svn = 'notundersvn'
- cfstat = curfile_statusType
- } else throw e
- }
- if (curfile_svn != 'notundersvn' ) {
- curfile_status_r = clientManager.getStatusClient().doStatus(curfile, true, true)
- SVNStatusType curfile_statusType = curfile_status_r.getContentsStatus()
- cfstat = curfile_statusType
- }
- SVNStatusType folder_statusType = folder_status_r.getContentsStatus();
- SVNStatusType projsav_statusType = projsav_status_r.getContentsStatus();
- SVNStatusType glos_statusType = glos_status_r.getContentsStatus();
- console.println "\n"
- console.println "Project folder status: " +folder_statusType+"\n"
- console.println "project_save.tmx status: "+projsav_statusType+"\n"
- console.println "Glossary status: "+glos_statusType+"\n"
- console.println "Current file status: "+cfstat
- final def title = 'SVN status'
- final def msg = "Project folder status: " +folder_statusType+"\n"+"project_save.tmx status: "+projsav_statusType+"\n"+"Glossary status: "+glos_statusType+"\n"+"Current file status: " + cfstat
- showMessageDialog null, msg, title, INFORMATION_MESSAGE
- return
- }else{
- console.println "Not a Team project" }
- final def title = 'SVN status'
- final def msg = 'Status unavailable.\nNot a Team project.'
- showMessageDialog null, msg, title, INFORMATION_MESSAGE
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement