[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] Problem in executing CVS commands  XML
Forum Index » JCVS Mailing List
Author Message
jcvslist


[Avatar]

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

<pre>I can't execute CVS commands. Tim told me to see some files,

> Look at ProjectFrame in com.ice.jcvsii, specifically
> commonCVSCommand() and getEntriesToActUpon()

Raymond told me to use CVSProject methods to create a CVSEntry, but the
ones he said don't appear in the toolkit...

So I wrote some code, but results are not good. I try to attach it; many
thanks to eachone who has got time to have a look and say what I'm
missing or what I'm wrong.

/**************************************/
public void log()
{
File localRootDir = new File(localDirectory);
if (!localRootDir.exists() && !listingModules)
{
if (!localRootDir.mkdirs())
{
System.err.println("Cannot create local root directory");
return;
}
}
boolean allOk = true;

CVSArgumentVector arguments = new CVSArgumentVector();
CVSArgumentVector globalArguments = new CVSArgumentVector();

// This is the file I want to log; Codemart is Module name
arguments.appendArgument("Codemart/CVSLogger.java");

System.out.println("" + arguments);
int cvsPort = computePortNum(thisRep.getConnMethod(),
thisRep.isPServer());

// This is command line
String command = new String("log:A:E:dft: ");


CVSRequest request = new CVSRequest();

request.setArguments( new CVSArgumentVector() );
request.setGlobalArguments( new CVSArgumentVector());

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


CVSProject project = new CVSProject(client);
try
{
project.openProject(localRootDir);
}
catch (IOException ex)
{
System.out.println("Can't open the project!");
}


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

project.setProjectDef(projectDef);
project.setUserName("paolo");
project.setTempDirectory("/home/paolo/prova_checkout/tmp_checkout");
project.setRepository("Codemart");
project.setRootDirectory("/home/cvs-repos/paolo");
project.setLocalRootDirectory("/home/paolo/prova_checkout");
project.setPServer(false);
project.setConnectionPort(cvsPort);
project.setConnectionMethod(CVSRequest.METHOD_RSH);

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);
}

project.establishRootEntry(thisRep.getCvsRoot());

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.getCvsRoot());



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.appendArguments(arguments);
request.appendGlobalArguments(globalArguments);


request.setUserInterface(this);

allOk = request.parseControlString( command );


CVSEntry entry = project.getRootEntry();
entry.setLocalDirectory("Codemart");
entry.setRepository("/home/cvs-repos/paolo/Codemart/");
entry.setName("./CVSLogger.java");

CVSEntryVector entries = new CVSEntryVector();
entries.appendEntry(entry);
System.out.println("----->" + entry.getLocalDirectory());
System.out.println(" " + entry.getRepositoryName());
System.out.println(" " + entry.getRepository());


request.setEntries(entries);

System.out.println("----------");
System.out.println("" + project.getEntryFile(entry));
System.out.println("" + project.getRepository());
System.out.println("" + project.getRootDirectory());
System.out.println("" + project.getRootEntry());


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);
}
}


System.out.println("" + request.getEntrySelector() + " - " +
CVSRequest.ES_NONE);

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)
{
}

if (response.getStatus() == CVSResponse.OK )
{
uiDisplayProgressMsg("log executed with success");
if (!listingModules)
{
File rootDirFile = new File(request.getLocalDirectory() +
"/" + request.getRepository());

}
}
else
{
this.uiDisplayProgressMsg("Failed to log");
}

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

I attach output too:

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.
protocol error: directory '/home/cvs-repos/paolo/Codemart' not within
root '/home/cvs-repos/paolo/'

** The command completed with an error status.


--
Saluti,
Paolo

</pre>

jCVS Maoiling List arvhive.
[WWW]
jcvslist


[Avatar]

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

<pre>Paolo,

Sorry for the misleading method names. This is how I set up my entries:


String rootDir = // root directory...
String localDir = // local directory...
String args[] = // set up arguments here...for log it would be a list of
filenames
CVSProject project = // set up project here...
CVSRequest request = // set up request here...

project.establishRootEntry(rootDir);
project.setLocalDirectory(localDir);
project.openProject(new File(localDir));

CVSEntryVentor entries = new CVSEntryVector();
CVSArgumentVector argV = new CVSArgumentVector();
for (int i = 0; i < args.length; i++)
{
argV.appendArgument(args[i]);

CVSEntry entry = project.locateEntry("./" + args[i]);
if (entry != null)
{
entries.appendEntry(entry);
}
}
request.appendArguments(argV);
request.setEntries(entries);


HTH,
Ray

</pre>

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