shilpa_rajith
asked on
Using Javacvs to interact with CVS from Java programming. Problem in remove file.
Hi All,
I am using JavaCvs (cvs client library - NetBeans ) in my java application to communicate with CVS repository. My Add, update, checkout, checkin operations seems to be working fine. But when I remove a file using RemoveCommand, the file seems to be removed. But If i upload another file with the same name into the same directory path , for some reason instead of uploading the new file its getting back (recovering) the previous file. I don't know why its doing that. Below is the example to illustrate the problem better.
1) Added a file A.txt using AddCommand to CVS. (Say file A.txt's content A#).
2) Viewed the file A.txt. It showed the content A#
3) Removed the file using RemoveCommand followed by CommitCommnad from CVS.
4) Modified the file A.txt (Say file A.txt's content B#) in my local dir.
5) Added the file A.txt to CVS using AddCommand.
6) Viewed the file A.txt. It showed the content A# instead of B#. Its not adding the new file instead its considering (recovering) the old file it seems.
I did the above operations from Java program using netbean's javacvs api. I don't gave any local working folder, as i am using cvs to store some documents.
I don't know why its behaving that way. Please help me resolve this issue.
Thanks in advance.
Here is my code for removeing the file from cvs.
c = new PServerConnection();
c.setUserName(username);
c.setEncodedPassword(passw
c.setHostName(host);
c.setRepository(reppath);
c.verify();
c.open();
RPCvsClient client = new RPCvsClient(c, new RPAdminHandler());
client.getEventManager().a
client.setRepositoryFullPa
Entry ent = new Entry();
ent.setDirectory(false);
ent.setName(fileName);
ent.setRevision("1");
ByteArrayOutputStream streamForCVS = null;
client.setEntry(null, ent);
ent.setFileStream(streamFo
client.setLocalPath(repPat
StatusCommand command = new StatusCommand();
GlobalOptions globalOptions = new GlobalOptions();
client.executeCommand(comm
StatusBuilder sb = (StatusBuilder) command.getBuilder();
StatusInformation si = sb.getStatusInformation();
if ( si != null )
{
}
String repositoryVersionOfFileToB
c.close();
c.open();
client.setRepositoryFullPa
ent = new Entry();
ByteArrayOutputStream stream = null;
ent.setDirectory(false);
ent.setName(fileName);
ent.setRelativePath(direct
ent.setFileStream(stream);
client.setLocalPath(reppat
ent.setOptions("-kb");
client.setEntry(null, ent);
ent.setFileStream(stream);
RemoveCommand removeCommand = new RemoveCommand();
removeCommand.setIgnoreLoc
globalOptions = new GlobalOptions();
client.executeCommand(remo
c.close();
// Now commit the delete
c.open();
client = new RPCvsClient(c, new RPAdminHandler());
client.getEventManager().a
client.setRepositoryFullPa
ent = new Entry();
stream = new ByteArrayOutputStream(); // faking out the file
ent.setDirectory(false);
ent.setName(fileName);
ent.setRelativePath(direct
ent.setRevision("-"+reposi
ent.setFileStream(stream);
client.setLocalPath(reppat
client.setEntry(null, ent); // no need to set the file. hence set to null.
CommitCommand commitCommand = new CommitCommand();
commitCommand.setDeleteCom
commitCommand.setForceComm
commitCommand.setMessage(l
globalOptions = new GlobalOptions();
client.setCommand(commitCo
client.executeCommand(comm
c.close();
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the response.
Hi Objects,
In my application the users will upload their documents. Behind the scene I am storing the documents in CVS. So when the users upload their documents, the application will add them to CVS. When the user wants to view them, then the app will get it from CVS and show them. Basically its kind of document management. So i don't have a local copy as such here. OR i don't know if i am missing something here.
How do i remove the file from History ??
Hi aozarov,
I am calling client.executeCommand() with CommitCommand after RemoveCommand. You can find that at the botton of my code.
Thanks in advance.