1 11 package org.eclipse.team.internal.ccvs.core.client; 12 13 14 import java.util.Collection ; 15 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.core.runtime.IStatus; 19 import org.eclipse.core.runtime.Status; 20 import org.eclipse.osgi.util.NLS; 21 import org.eclipse.team.internal.ccvs.core.*; 22 import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; 23 24 public class Commit extends Command { 25 26 public static final LocalOption FORCE = new LocalOption("-f"); 33 protected Commit() { } 34 protected String getRequestId() { 35 return "ci"; } 37 38 42 protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, 43 LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) 44 throws CVSException { 45 46 checkResourcesManaged(session, resources); 48 49 ModifiedFileSender visitor = new ModifiedFileSender(session, localOptions); 51 visitor.visit(session, resources, monitor); 52 53 ICVSFile[] changedFiles = visitor.getModifiedFiles(); 55 for (int i = 0; i < changedFiles.length; i++) { 56 session.sendArgument(changedFiles[i].getRelativePath(session.getLocalRoot())); 57 } 58 return changedFiles; 59 } 60 61 64 protected IStatus commandFinished(Session session, GlobalOption[] globalOptions, 65 LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor, 66 IStatus status) throws CVSException { 67 if (status.getCode() == CVSStatus.SERVER_ERROR) { 69 return status; 70 } 71 72 if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) { 74 new PruneFolderVisitor().visit(session, resources); 75 } 76 77 if (status.isOK()) { 80 for (int i = 0; i < resources.length; i++) { 81 ICVSResource resource = resources[i]; 82 if (!resource.isFolder()) { 83 ICVSFile cvsFile = (ICVSFile)resources[i]; 84 if (cvsFile.exists() && cvsFile.isModified(null)) { 85 status = mergeStatus(status, clearModifiedState(cvsFile)); 86 } 87 } 88 } 89 } 90 return status; 91 } 92 93 protected IStatus clearModifiedState(ICVSFile cvsFile) throws CVSException { 94 byte[] info = cvsFile.getSyncBytes(); 95 IResource resource = cvsFile.getIResource(); 96 String filePath; 97 if (resource == null) { 98 filePath = cvsFile.getRepositoryRelativePath(); 99 } else { 100 filePath = resource.getFullPath().toString(); 101 } 102 if (info == null) { 103 return new Status(IStatus.WARNING, CVSProviderPlugin.ID, 0, NLS.bind(CVSMessages.Commit_syncInfoMissing, new String [] { filePath }), null); 105 } 106 cvsFile.checkedIn(null, true ); 107 return new Status(IStatus.INFO, CVSProviderPlugin.ID, 0, NLS.bind(CVSMessages.Commit_timestampReset, new String [] { filePath }), null); } 109 110 114 protected void sendArguments(Session session, String [] arguments) throws CVSException { 115 } 116 117 public final IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, 118 ICVSResource[] arguments, Collection filesToCommitAsText, 119 ICommandOutputListener listener, IProgressMonitor pm) throws CVSException { 120 121 session.setTextTransferOverride(filesToCommitAsText); 122 try { 123 return super.execute(session, globalOptions, localOptions, arguments, listener, pm); 124 } finally { 125 session.setTextTransferOverride(null); 126 } 127 } 128 129 protected String getDisplayText() { 130 return "commit"; } 132 } 133 | Popular Tags |