[Logo] JCVSForum - Community Support For JCVS Users and Developers
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[jcvs] Log command  XML
Forum Index » JCVS Mailing List
Author Message
jcvslist


[Avatar]

Joined: 03/06/2004 19:54:53
Messages: 3096
Location: Earth
Offline

<pre>Hi. I need to use jCVS and cvsc to log a file in a CVS repository, in a tool I'm
building. I tried to read sources and I found in `CheckOutPanel.java' the list
of steps I need to execute a checkout. Then I tried to readapt them to have a
log of a file.
Looking at `CVSRequest.java' in parseControlString method I discovered a list of
flags I can use (btw, there is a reference to CVSRequestSpec.html not valid).
Then I set a command as follows,

':log:N:MA:cdefimoukt: CVSLogger.java'

in order to send the root and the module to cvs server; `CVSLogger.java' is the
file whose I need the log.
I attach my source code (which is mostly equal to ChekOutPanel.java) Please,
could you tell me hot to solve my problem? Thank for your time

/***************************************************************/
localDirectory = CVSCUtilities.stripFinalSeparator(localDirectory);
int cvsPort = computePortNum(thisRep.getConnMethod(), thisRep.isPServer());

//argumentStr = "DBUpdater.jav";
CVSArgumentVector arguments = CVSArgumentVector.parseArgumentString(
argumentStr);
if (!checkData(arguments)) return;
System.out.println("" + arguments);

File localRootDir = new File(localDirectory);
if (!localRootDir.exists() && !listingModules)
{
if (!localRootDir.mkdirs())
{
System.err.println("Cannot create local root directory");
return;
}
}

CVSRequest request = new CVSRequest();

//String checkOutCommand = ":co:N:ANP:deou:";
command = "log:N:MA:cdefimoukt: -R -l";

if (!request.parseControlString(command ))
{
System.err.println("ERROR: Checkout command parse failed");
return;
}
//request.setServerCommand("log");
request.sendArguments = true;
System.out.println("" + request.toString());

CVSEntryVector entries = new CVSEntryVector();
if (!listingModules)
{
arguments.appendArgument(thisRep.getModule());
}


CVSClient client = new CVSClient();
client.setHostName(thisRep.getHostName());
client.setPort(cvsPort);


CVSProject project = new CVSProject(client);


CVSProjectDef projectDef = new CVSProjectDef(
thisRep.getConnMethod(), thisRep.isPServer(), false,
thisRep.getHostName(), thisRep.getUserName(),
thisRep.getCvsRoot(), thisRep.getModule());

project.setProjectDef(projectDef);

project.setUserName(thisRep.getUserName());
project.setTempDirectory(tempDir);
project.setRepository(thisRep.getModule());
project.setRootDirectory(thisRep.getCvsRoot());
project.setLocalRootDirectory(localDirectory);
project.setPServer(thisRep.isPServer());
project.setConnectionPort(cvsPort);
project.setConnectionMethod(thisRep.getConnMethod());

project.setSetVariables(null);

project.setServerCommand(establishServerCommand(thisRep.getHostName(),
thisRep.getConnMethod(), thisRep.isPServer()));

project.setAllowsGzipFileMode(false);
project.setGzipStreamLevel(0);

if (thisRep.isPServer())
{
String scrambled = CVSScramble.scramblePassword(thisRep.getPassword(),
'A' );
project.setPassword(scrambled);
}
else if (thisRep.getConnMethod() == CVSRequest.METHOD_SSH )
{
project.setPassword(thisRep.getPassword());
}

if (thisRep.getConnMethod() == CVSRequest.METHOD_RSH )
{
establishRSHProcess(project);
}

// Finally, we must make sure that the Project has its root entry, as
// CVSProject will not be able to create it from the context that the
// server will send with the checkout.

project.establishRootEntry(thisRep.getCvsRoot());

// UNDONE
// IF IT IS ALREADY OPEN, we should tell the ProjectFrame to do this!!!
//

String title = thisRep.getModule() + " project";

// NOTE that all of these redundant setters on request are
// needed because we are not using the typicall call to
// CVSProject.performCVSCommand(), which calls most of
// these setters for us.

request.setPServer(thisRep.isPServer());
request.setUserName(thisRep.getUserName());

if (thisRep.isPServer() ||
thisRep.getConnMethod() == CVSRequest.METHOD_SSH )
{
request.setPassword( project.getPassword() );
}

request.setConnectionMethod(thisRep.getConnMethod());
request.setServerCommand(project.getServerCommand());
request.setRshProcess(rshPath);

request.setPort(cvsPort);
request.setHostName(client.getHostName() );

request.setRepository(thisRep.getModule());
request.setRootDirectory(thisRep.getCvsRoot());
request.setRootRepository(thisRep.getCvsRoot());
request.setLocalDirectory(localRootDir.getPath());

request.setSetVariables(project.getSetVariables());

request.responseHandler = project;

request.traceRequest = CVSProject.overTraceRequest;
request.traceResponse = CVSProject.overTraceResponse;
request.traceTCPData = CVSProject.overTraceTCP;
request.traceProcessing = CVSProject.overTraceProcessing;

request.allowGzipFileMode = project.allowsGzipFileMode();
request.setGzipStreamLevel(project.getGzipStreamLevel());

request.setEntries(entries);
request.appendArguments(arguments);

request.setUserInterface(this);

CVSResponse response = new CVSResponse();

client.processCVSRequest(request, response);
if (!listingModules)
{
project.processCVSResponse(request, response);
if (request.getArguments().containsArgument( "-P") ||
request.getArguments().containsArgument( "-r" ) ||
request.getArguments().containsArgument( "-D" ) )
{
project.pruneEmptySubDirs(request.handleEntries);
}
}

// Final phase
String resultStr = response.getDisplayResults();

try
{
PrintStream tmp = System.out;
PrintStream out = new PrintStream(new FileOutputStream("./antan.log"));
PrintStream tee = new TeeStream(System.out, out);
System.setOut(tee);
System.out.println(resultStr);
System.setOut(tmp);
System.out.println("Ciao");
out.close();
}
catch (FileNotFoundException e)
{
}
//response.deleteTempFiles();
/*
response.printResponse(new PrintStream(new FileOutputStream("antan.log")));
*/

if (response.getStatus() == CVSResponse.OK )
{
uiDisplayProgressMsg("Checkout executed with success");
if (!listingModules)
{
File rootDirFile = new File(request.getLocalDirectory() +
"/" + request.getRepository());
//
/*ProjectFrame.openProject
( rootDirFile, request.getPassword() );*/
}
}
else
{
this.uiDisplayProgressMsg("Failed to checkout");
}

if (response != null && ! request.saveTempFiles)
{
response.deleteTempFiles();
}


</pre>

jCVS Maoiling List arvhive.
[WWW]
jcvslist


[Avatar]

Joined: 03/06/2004 19:54:53
Messages: 3096
Location: Earth
Offline

<pre>Tim Endres wrote:

> You cannot put the file name in the CVSSpec. You need to add it to
the arguments
> of the command via the argument vector.
>
> tim.


Well, I tried to set

command = "log:N:MA:cdefimoukt: -R -l"

and

argumentStr = "DBUpdater.java";

In fact, in the source code of `CheckOutPanel.java', there is the
following statement,

CVSArgumentVector arguments =
CVSArgumentVector.parseArgumentString(argumentStr);

which parses `argumentStr' and sets the up the argument vector. I
launched my app and this is what I can see:

CVSRequest: command=log
Opening server '514@arale.lips.dist.unige.it'...
Negotiating cvs protocol...
Sending command request, 'log'...
Reading server response...
Closing CVS server connection.
Command completed with 'ok' status.
cvs server: Logging .

** The command completed successfully.

The result doesn't change if I change the name of the file I want to log
or if the name points to a non existing file in my repository. Could you
tell me where I can read documentation or what are the source file
responsible to execute the log of a file?

The result I expect is something like

M RCS file: /home/cvspublic/apache-1.2/src/alloc.h,v
M Working file: apache-1.2/src/alloc.h
M head: 1.22
M branch:
M locks: strict
M keyword substitution: kv
M total revisions: 23; selected revisions: 23
M description:
M ----------------------------
M revision 1.22
M date: 1998/04/13 11:45:37; author: coar; state: Exp; lines: +8 -3
M
M Reword the licence text surrounding the use of the name "Apache"
M in derived products. This will be in effect as of 1.2.7 and
M following. (It's already in place for 1.3 in development.)
M ----------------------------
M revision 1.21
M date: 1997/05/27 04:14:19; author: fielding; state: Exp; lines: +1 -0
M Two problems were introduced by the two "error responses have wrong
headers"
M patches committed a couple weeks ago. The first is that a NULL table
M causes mod_log_config to SIGSEGV on a call to table_get; the second is
M that Location needs to be added to the output header table for redirects.
M
M Submitted by: Roy Fielding and Ed Korthof
M Reviewed by: Jim Jagielski, Randy Terbush

and so on.

Thanks a lot for your help

--
Saluti,
Paolo

</pre>

jCVS Maoiling List arvhive.
[WWW]
jcvslist


[Avatar]

Joined: 03/06/2004 19:54:53
Messages: 3096
Location: Earth
Offline

<pre>Did you try adding an entry to the list for the file you want? Also,
you could try using "rlog" instead of "log".

Ray

</pre>

jCVS Maoiling List arvhive.
[WWW]
jcvslist


[Avatar]

Joined: 03/06/2004 19:54:53
Messages: 3096
Location: Earth
Offline

<pre>I tried to do what Tim suggested, but I'm here again...

Tim told me to setup an Entry for each file to be processed, o I added:

CVSEntry entry = new CVSEntry();
entry.setLocalDirectory("/home/paolo/prova_checkout");
entry.setRepository("Codemart/");
entry.setName("CVSLogger.java");

where "/home/paolo/prova_checkout" is the local directory in which I
executed the checkout, "Codemart/" is the module contained in CVS server
and "CVSLogger.java" is the file I want to log.

The command I use is

String command = new String("log:A:FMA:cdefimoukt: -l -R ");

First `A' flag means that each entry must be parsed; FMA flags mean to
send module name (in my case that should be "Codemart"), entries and
arguments.

At this point Tim said to add an argument:

CVSArgumentVector arguments = new CVSArgumentVector();
arguments.appendArgument("CVSLogger.java");

If I launch my app, that's the result:

Opening server '514@arale.lips.dist.unige.it'...
Negotiating cvs protocol...
Sending command request, 'log'...
Reading server response...
Closing CVS server connection.
Command completed with 'error' status.
cvs [server aborted]: absolute pathname
`/home/paolo/prova_checkout/CVSLogger.java' illegal for server

If I understand correctly server message, it receives the local path
instead of the remote path ("/home/paolo/prova_checkout" is where I
executed checkout on my machine). Where am I wrong?

Thanks for your time

--
Saluti,
Paolo

</pre>

jCVS Maoiling List arvhive.
[WWW]
jcvslist


[Avatar]

Joined: 03/06/2004 19:54:53
Messages: 3096
Location: Earth
Offline

<pre>Paolo Gambetti wrote:
> I tried to do what Tim suggested, but I'm here again...
>
> Tim told me to setup an Entry for each file to be processed, o I added:
>
> CVSEntry entry = new CVSEntry();
> entry.setLocalDirectory("/home/paolo/prova_checkout";
> entry.setRepository("Codemart/";
> entry.setName("CVSLogger.java";
>
> where "/home/paolo/prova_checkout" is the local directory in which I
> executed the checkout, "Codemart/" is the module contained in CVS server
> and "CVSLogger.java" is the file I want to log.
>

Paolo,

When using entries I have had success using the following technique.
First, create a CVSProject and use the open command to initialize it.
(Sorry, I do not have my documentation handy, I think the method is
something like "openProject()"). Then use the findEntry() methods on
CVSProject to get the CVSEntry objects (do not create them yourself).
When passing the entry name, always start the name with "./". For
example, if the local directory is /home/paolo/prova_checkout and the
file is Codemart/CVSLogger.java, use "./Codemart/CVSLogger.java".

Good luck,
Ray

</pre>

jCVS Maoiling List arvhive.
[WWW]
 
Forum Index » JCVS Mailing List
Go to:   
Powered by JForum 2.1.9 © JForum Team