Trying to implement Rollback Command
saad tawwab <[email protected]> Fri, 12 Jul 2002 11:49:27 +0500
| Newsgroups | gmane.comp.java.netbeans.modules.javacvs.devel |
|---|---|
| Message-ID | <1116E95CE267D211929700C0F0313C3E20FBC7@JOHNYQUEST> |
Hello!! I am trying to implement the Rollback command using the command that have already been implemented in the CVSLib. I am following the "Fast Method of Reverting" scheme from the PostScript version of Karl Fogel's book (this method/scheme is listed on the page # 36 of his book). The file is reverted to the previous version but I encounter an EOF Exception. Is this exception fatal or can I just ignore it. Is there anyway of stopping for the exception to be thrown. I have attached my code for the method that is responsible for implementing the rollback command and the console output along with the exception. Regards, Saad Tawwab --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
rollbackCode.txt
(text/plain, 3.5 KB)
public void rollbackDocument(String path, String rollbackVersion, String currentVersion){
/*
The Utilities function is just responsible for initializing the GlobalOptions object
*/
GlobalOptions globalOptions= Utilities.getGlobalOptionsObject(this.repository);
/*
The Utilities function is just responsible for getting a PServerConnection
*/
PServerConnection pserverConnection = Utilities.getPServerConnection(this.userName,
this.password,
this.hostName,
this.repository);
String localDirectory;
localDirectory = Utilities.getWorkingDirectory(path);
Client client = new Client(pserverConnection, new StandardAdminHandler());
client.setLocalPath(localDirectory);
client.getEventManager().addCVSListener(new BasicListener());
UpdateCommand command = new UpdateCommand();
command.setBuilder(null);
command.setRecursive(true);
command.setBuildDirectories(false);
command.setPruneDirectories(false);
File tempFile = new File(path);
File[] files = new File[1];
files[0]=tempFile;
// The j arguments that need to be set
command.setCVSCommand('j',currentVersion);
command.setCVSCommand('j',rollbackVersion);
command.setFiles(files);
try{
System.out.println(command.getCVSCommand());
client.executeCommand(command, globalOptions);
}
catch(CommandAbortedException cae){
System.out.println("Inside CommandAbortedException");
}
catch(CommandException ce){
System.out.println("Inside CommandException");
ce.printStackTrace(System.out);
}
GlobalOptions newGlobalOptions= Utilities.getGlobalOptionsObject(this.repository);
PServerConnection newPserverConnection = Utilities.getPServerConnection(this.userName,
this.password,
this.hostName,
this.repository);
UpdateCommand updateCommand = new UpdateCommand();
updateCommand.setBuilder(null);
updateCommand.setRecursive(true);
updateCommand.setBuildDirectories(false);
updateCommand.setPruneDirectories(false);
Client tempClient = new Client(newPserverConnection, new StandardAdminHandler());
tempClient.setLocalPath(localDirectory);
tempClient.getEventManager().addCVSListener(new BasicListener());
File newTempFile = new File(path);
File[] newfiles = new File[1];
newfiles[0]=newTempFile;
updateCommand.setFiles(newfiles);
try{
System.out.println(updateCommand.getCVSCommand());
client.executeCommand(updateCommand, globalOptions);
}
catch(CommandAbortedException cae){
System.out.println("Inside CommandAbortedException");
}
catch(CommandException ce){
System.out.println("Inside CommandException");
ce.printStackTrace(System.out);
}
String[] pathToCommit = {path};
this.checkIn(pathToCommit);
}
EOFException.txt
(text/plain, 1.2 KB)
root :c:\newcvs connection established successfully update -j 1.28 -j 1.29 ummair.txt RCS file: c:/newcvs/buttx/ummair.txt,v retrieving revision 1.29 retrieving revision 1.28 Merging differences between 1.29 and 1.28 into ummair.txt root :c:\newcvs connection established successfully update ummair.txt Inside CommandException java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:224) at org.netbeans.lib.cvsclient.util.LoggedDataInputStream.readByte(LoggedDataInputStream.java:88) at org.netbeans.lib.cvsclient.Client.handleResponse(Client.java:461) at org.netbeans.lib.cvsclient.Client.processRequests(Client.java:442) at org.netbeans.lib.cvsclient.command.update.UpdateCommand.execute(UpdateCommand.java:294) at org.netbeans.lib.cvsclient.Client.executeCommand(Client.java:521) at referencelibrary.repository.LibraryRAO.rollbackDocument(LibraryRAO.java:199) at versioncontrol.Debug.<init>(Debug.java:25) at versioncontrol.Debug.main(Debug.java:34) root :c:\newcvs connection established successfully commit ummair.txt Checking in ummair.txt; c:/newcvs/buttx/ummair.txt,v <-- ummair.txt new revision: 1.30; previous revision: 1.29 done