How to retrieve the revision of a committed file?
[email protected] Fri, 16 Dec 2005 12:07:46 +0100
| Newsgroups | gmane.comp.java.netbeans.modules.javacvs.devel |
|---|---|
| Organization | http://freemail.web.de/ |
| Message-ID | <[email protected]> |
Hi all,
I'm new to the javacvs library, so apologize, if this is a stupid question...
I want to commit a file to the CVS repository, and read the response of the server to retrieve the revision of the file just checked in. What is the state-of-the-art way to do this?
Should I parse one the messages of a messageSent event (such as "new revision: 1.14; previous revision: 1.13"), or is there a more elegant way?
I wonder about the meaning of isTagged()... (never saw "true" in my tests).
Can I use the CommitInformation class for this purpose (and if so, how)?
Thanks a lot,
--
Manni
P.S.: The code of a sample app follows (without imports):
public class TestRetrieveRevision {
public class InfoListener extends CVSAdapter {
public void messageSent(MessageEvent e) {
// parse the message?? Or a more elegant way?
System.out.println("message: " + e.getMessage());
System.out.println("isTagged: " + e.isTagged()); // always false
}
}
private String cvsroot = ":pserver:mb@Halley:2401/srv/cvs/repository0";
private String passWord = "xxxxxx";
private String path = "D:/tmp/workingdir/testfile.txt";
private void doIt() throws AuthenticationException, CommandException {
GlobalOptions globalOptions = new GlobalOptions();
globalOptions.setCVSRoot(cvsroot);
PServerConnection connection =
new PServerConnection(CVSRoot.parse(cvsroot), SocketFactory.getDefault());
connection.setEncodedPassword(
StandardScrambler.getInstance().scramble(passWord));
connection.open();
// The files array contains exactly one File
File[] files = new File[1];
files[0] = new File(path);
String localPath = files[0].getParent();
Client client = new Client(connection, new StandardAdminHandler());
client.setLocalPath(localPath);
client.getEventManager().addCVSListener(new InfoListener());
// run the commit command
CommitCommand command = new CommitCommand();
command.setBuilder(
new CommitBuilder(client.getEventManager(), localPath, cvsroot));
command.setRecursive(false);
// set the file to be commited
command.setFiles(files);
System.out.println(command.getCVSCommand());
client.executeCommand(command, globalOptions);
}
public static void main(String[] args) throws AuthenticationException, CommandException {
TestRetrieveRevision test = new TestRetrieveRevision();
test.doIt();
}
}
__________________________________________________________________
Nur bis 31.12.: 1&1 DSL mit WEB.DE Preisvorteil! Jetzt einsteigen
und die Vorteile sichern! http://1und1dsl.web.de/?mc=021130