Re: Problem with Adding Files

Milos Kleint <[email protected]> Sun, 07 Jul 2002 08:35:52 +0200
Newsgroups gmane.comp.java.netbeans.modules.javacvs.devel
Message-ID <[email protected]>
saad tawwab wrote:

> Hello!!
>
> I want to Add files to a CVS Repository using the AddCommand. But the 
> method addRequests has protected context and cannot be accessed via an 
> instance of the class. I also tried to create a sub-class that 
> inherited from AddCommand class. But when I called the addRequests 
> method I got a StackOverflow error. I would be obliged if anybody 
> could point out the manner in which the AddCommand can be used correctly.
>

well, you don't need to extend AddCommand IMO.
Just use the command as any other command. Beware of one thing though.. 
cvs has a weird twist when dealing with cvs add..
you have to place your local directory in the dir where the file you 
want to add resides.
Otherwise you'll get bad results.

try to look at the stuff at 
org.netbeans.lib.cvsclient.commandLine.command.add.java
or org.netbeans.modules.javacvs.commands.CvsAdd.java

Milos

>
> Regards,
> Saad Tawwab
>
>
> *Code for my Wrapper Class.*
>
> *public class **Test**AddCommand extends AddCommand {*
>
> *  public TestAddCommand() {*
> *  }*
>
> *  public void addRequests(File file){*
> *      this.addRequests(file);*
> *  }*
>
> *}*
>
>
> *Code invoking the AddCommand.*
>
>             *Test**AddCommand command = new **Test**AddCommand();*
>
> *            command.setBuilder(null);*
> *            File tempFile  = new File("c:\\sandbox\\buttx");*
> *            File[] files = new File[1];*
> *            files[0]=tempFile;*
> *            command.setFiles(files);*
> *            command.addRequests(new File("saad.html"));*
> *           *
> *             try{*
> *             client.executeCommand(command, globalOptions);*
> *             }*
> *             catch(CommandAbortedException cae){*
> *                System.out.println("Inside CommandAbortedException");*
> *             }*
> *             catch(CommandException ce){*
> *                System.out.println("Inside CommandException");*
> *                ce.printStackTrace(System.out);*
> *                }*
>