Compatibility with a change in vcscore module: CommandsPool.waitToFinish() throws InterruptedException. release33_beta1-BLD200110221515
authormentlicher@netbeans.org
Wed, 17 Oct 2001 12:53:34 +0000
changeset 6646c3d4fc13e02
parent 663 e845a62c189f
child 665 863f61304bd2
Compatibility with a change in vcscore module: CommandsPool.waitToFinish() throws InterruptedException.
vcscvs/src/org/netbeans/modules/vcs/cmdline/Cust3CheckoutPanel.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/CvsFileSystem.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsBranches.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsCommit.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsLogInfo.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsModuleSelector.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionExplorer.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionListGetter.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionSelector.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsScheduledAdd.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsWatchStatus.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/compatinstall/CvsModuleInstall.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/list/CvsListCommand.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/list/CvsListRecursiveCommand.java
vcscvs/src/org/netbeans/modules/vcs/cmdline/passwd/CVSPasswd.java
     1.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/Cust3CheckoutPanel.java	Tue Oct 16 16:26:42 2001 +0000
     1.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/Cust3CheckoutPanel.java	Wed Oct 17 12:53:34 2001 +0000
     1.3 @@ -397,7 +397,12 @@
     1.4            public void run() {
     1.5                //es.start();
     1.6                cPool.startExecutor(vce);
     1.7 -              cPool.waitToFinish(vce);
     1.8 +              try {
     1.9 +                cPool.waitToFinish(vce);
    1.10 +              } catch (InterruptedException iexc) {
    1.11 +                  cPool.kill(vce);
    1.12 +                  return ;
    1.13 +              }
    1.14                /*
    1.15                try {
    1.16                    es.join();
     2.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/CvsFileSystem.java	Tue Oct 16 16:26:42 2001 +0000
     2.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/CvsFileSystem.java	Wed Oct 17 12:53:34 2001 +0000
     2.3 @@ -91,8 +91,11 @@
     2.4                          }
     2.5                      },null,false);
     2.6                      CommandsPool pool = CvsFileSystem.this.getCommandsPool();
     2.7 -                    for (int i=0; i< executors.length; i++)
     2.8 -                        pool.waitToFinish (executors[i]);
     2.9 +                    for (int i=0; i< executors.length; i++) {
    2.10 +                        try {
    2.11 +                            pool.waitToFinish (executors[i]);
    2.12 +                        } catch (InterruptedException iexc) {}
    2.13 +                    }
    2.14                      
    2.15                  }
    2.16                  // Next add $HOME/.cvsignore
     3.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsBranches.java	Tue Oct 16 16:26:42 2001 +0000
     3.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsBranches.java	Wed Oct 17 12:53:34 2001 +0000
     3.3 @@ -207,7 +207,11 @@
     3.4          diffArgs = new String[2];
     3.5          diffArgs[0] = this.args[1];
     3.6          diffArgs[1] = this.args[2];
     3.7 -        success = this.logInfo.updateLogInfo(this.vars, logInfoArg, this.stdoutNRListener, this.stderrNRListener);
     3.8 +        try {
     3.9 +            success = this.logInfo.updateLogInfo(this.vars, logInfoArg, this.stdoutNRListener, this.stderrNRListener);
    3.10 +        } catch (InterruptedException iexc) {
    3.11 +            success = false;
    3.12 +        }
    3.13          return success;
    3.14      }
    3.15      
     4.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsCommit.java	Tue Oct 16 16:26:42 2001 +0000
     4.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsCommit.java	Wed Oct 17 12:53:34 2001 +0000
     4.3 @@ -339,7 +339,14 @@
     4.4          //cpool.startExecutor(commit);
     4.5          //return preprocessStatus;
     4.6          for (int i = 0; i < executors.length; i++) {
     4.7 -            cpool.waitToFinish(executors[i]);
     4.8 +            try {
     4.9 +                cpool.waitToFinish(executors[i]);
    4.10 +            } catch (InterruptedException iexc) {
    4.11 +                for (int j = i; j < executors.length; j++) {
    4.12 +                    cpool.kill(executors[j]);
    4.13 +                }
    4.14 +                return new VcsCommandExecutor[0];
    4.15 +            }
    4.16          }
    4.17          return executors;
    4.18      }
    4.19 @@ -375,7 +382,12 @@
    4.20              });
    4.21              cpool.preprocessCommand(template, vars);
    4.22              cpool.startExecutor(template);
    4.23 -            cpool.waitToFinish(template);
    4.24 +            try {
    4.25 +                cpool.waitToFinish(template);
    4.26 +            } catch (InterruptedException iexc) {
    4.27 +                cpool.kill(template);
    4.28 +                return false;
    4.29 +            }
    4.30              String buffered = buff.toString();
    4.31              String fsRoot = ((String) vars.get("ROOTDIR")) + ps + vars.get("MODULE");
    4.32              fsRoot = fsRoot.replace('/', ps);
     5.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsLogInfo.java	Tue Oct 16 16:26:42 2001 +0000
     5.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsLogInfo.java	Wed Oct 17 12:53:34 2001 +0000
     5.3 @@ -138,14 +138,19 @@
     5.4  
     5.5      public boolean updateLogInfo(Hashtable vars, String cmdName,
     5.6                                   CommandOutputListener stdoutListener,
     5.7 -                                 CommandOutputListener stderrListener) {
     5.8 +                                 CommandOutputListener stderrListener) throws InterruptedException {
     5.9          revisionGraph = new CvsRevisionGraph();
    5.10          mergeIsEmpty = true;
    5.11          VcsCommand cmd = fileSystem.getCommand(cmdName);
    5.12          VcsCommandExecutor vce = fileSystem.getVcsFactory().getCommandExecutor(cmd, new Hashtable(vars));
    5.13          vce.addDataOutputListener(this);
    5.14          fileSystem.getCommandsPool().startExecutor(vce);
    5.15 -        fileSystem.getCommandsPool().waitToFinish(vce);
    5.16 +        try {
    5.17 +            fileSystem.getCommandsPool().waitToFinish(vce);
    5.18 +        } catch (InterruptedException iexc) {
    5.19 +            fileSystem.getCommandsPool().kill(vce);
    5.20 +            throw iexc;
    5.21 +        }
    5.22          if (vce.getExitStatus() != VcsCommandExecutor.SUCCEEDED) {
    5.23              E.err("exec failed "+vce.getExitStatus()); // NOI18N
    5.24              return false;
     6.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsModuleSelector.java	Tue Oct 16 16:26:42 2001 +0000
     6.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsModuleSelector.java	Wed Oct 17 12:53:34 2001 +0000
     6.3 @@ -183,8 +183,14 @@
     6.4          CommandsPool pool = fileSystem.getCommandsPool();
     6.5          pool.startExecutor(vce1);
     6.6          pool.startExecutor(vce2);
     6.7 -        pool.waitToFinish(vce1);
     6.8 -        pool.waitToFinish(vce2);
     6.9 +        try {
    6.10 +            pool.waitToFinish(vce1);
    6.11 +            pool.waitToFinish(vce2);
    6.12 +        } catch (InterruptedException iexc) {
    6.13 +            pool.kill(vce1);
    6.14 +            pool.kill(vce2);
    6.15 +            return false;
    6.16 +        }
    6.17          boolean modulesStatGetStatus = vce1.getExitStatus() == VcsCommandExecutor.SUCCEEDED;
    6.18          boolean modulesAllGetStatus = vce2.getExitStatus() == VcsCommandExecutor.SUCCEEDED;
    6.19          return modulesStatGetStatus && modulesAllGetStatus;
     7.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionExplorer.java	Tue Oct 16 16:26:42 2001 +0000
     7.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionExplorer.java	Wed Oct 17 12:53:34 2001 +0000
     7.3 @@ -101,7 +101,12 @@
     7.4          VcsCommandExecutor vce = fileSystem.getVcsFactory().getCommandExecutor(logCmd, vars);
     7.5          vce.addDataOutputListener(this);
     7.6          fileSystem.getCommandsPool().startExecutor(vce);
     7.7 -        fileSystem.getCommandsPool().waitToFinish(vce);
     7.8 +        try {
     7.9 +            fileSystem.getCommandsPool().waitToFinish(vce);
    7.10 +        } catch (InterruptedException iexc) {
    7.11 +            fileSystem.getCommandsPool().kill(vce);
    7.12 +            return false;
    7.13 +        }
    7.14          if (vce.getExitStatus() != VcsCommandExecutor.SUCCEEDED) {
    7.15              //E.err("exec failed "+ec.getExitStatus()); // NOI18N
    7.16              return false;
     8.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionListGetter.java	Tue Oct 16 16:26:42 2001 +0000
     8.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionListGetter.java	Wed Oct 17 12:53:34 2001 +0000
     8.3 @@ -104,7 +104,12 @@
     8.4          VcsCommandExecutor vce = fileSystem.getVcsFactory().getCommandExecutor(logCmd, vars);
     8.5          vce.addDataOutputListener(this);
     8.6          fileSystem.getCommandsPool().startExecutor(vce);
     8.7 -        fileSystem.getCommandsPool().waitToFinish(vce);
     8.8 +        try {
     8.9 +            fileSystem.getCommandsPool().waitToFinish(vce);
    8.10 +        } catch (InterruptedException iexc) {
    8.11 +            fileSystem.getCommandsPool().kill(vce);
    8.12 +            return false;
    8.13 +        }
    8.14          if (vce.getExitStatus() != VcsCommandExecutor.SUCCEEDED) {
    8.15              //E.err("exec failed "+ec.getExitStatus()); // NOI18N
    8.16              return false;
     9.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionSelector.java	Tue Oct 16 16:26:42 2001 +0000
     9.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsRevisionSelector.java	Wed Oct 17 12:53:34 2001 +0000
     9.3 @@ -92,7 +92,12 @@
     9.4              argsCmd = args[startArg];
     9.5              startArg++;
     9.6          }
     9.7 -        boolean success = this.logInfo.updateLogInfo(vars, argsCmd, stdoutNRListener, stderrNRListener);
     9.8 +        boolean success;
     9.9 +        try {
    9.10 +            success = this.logInfo.updateLogInfo(vars, argsCmd, stdoutNRListener, stderrNRListener);
    9.11 +        } catch (InterruptedException iexc) {
    9.12 +            success = false;
    9.13 +        }
    9.14          if (success) {
    9.15              Vector revisions;
    9.16              if (branch) {
    10.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsScheduledAdd.java	Tue Oct 16 16:26:42 2001 +0000
    10.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsScheduledAdd.java	Wed Oct 17 12:53:34 2001 +0000
    10.3 @@ -173,7 +173,12 @@
    10.4          VcsCommand cmd = fileSystem.getCommand(args[0]);
    10.5          VcsCommandExecutor vce = fileSystem.getVcsFactory().getCommandExecutor(cmd, vars);
    10.6          fileSystem.getCommandsPool().startExecutor(vce);
    10.7 -        fileSystem.getCommandsPool().waitToFinish(vce);
    10.8 +        try {
    10.9 +            fileSystem.getCommandsPool().waitToFinish(vce);
   10.10 +        } catch (InterruptedException iexc) {
   10.11 +            fileSystem.getCommandsPool().kill(vce);
   10.12 +            return false;
   10.13 +        }
   10.14          return vce.getExitStatus() == VcsCommandExecutor.SUCCEEDED;
   10.15      }
   10.16      
    11.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsWatchStatus.java	Tue Oct 16 16:26:42 2001 +0000
    11.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsWatchStatus.java	Wed Oct 17 12:53:34 2001 +0000
    11.3 @@ -69,7 +69,11 @@
    11.4              }
    11.5          });
    11.6          fileSystem.getCommandsPool().startExecutor(vce);
    11.7 -        fileSystem.getCommandsPool().waitToFinish(vce);
    11.8 +        try {
    11.9 +            fileSystem.getCommandsPool().waitToFinish(vce);
   11.10 +        } catch (InterruptedException iexc) {
   11.11 +            return false;
   11.12 +        }
   11.13          String[] elements = new String[3];
   11.14          String watched = buff.toString();
   11.15          elements[0] = new Boolean(watched.indexOf(EDIT) > 0).toString();
    12.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/compatinstall/CvsModuleInstall.java	Tue Oct 16 16:26:42 2001 +0000
    12.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/compatinstall/CvsModuleInstall.java	Wed Oct 17 12:53:34 2001 +0000
    12.3 @@ -26,6 +26,8 @@
    12.4  import org.openide.modules.ModuleInstall;
    12.5  import org.openide.modules.ModuleInfo;
    12.6  import org.openide.util.Lookup;
    12.7 +import org.openide.util.LookupEvent;
    12.8 +import org.openide.util.LookupListener;
    12.9  
   12.10  /**
   12.11   *
   12.12 @@ -35,6 +37,7 @@
   12.13      
   12.14      private static final String VCS_GENERIC_CODE_NAME_BASE = "org.netbeans.modules.vcs.advanced"; // NOI18N
   12.15      private static final String VCS_CVS_COMPAT_MODULE_FILE = "org-netbeans-modules-vcs-cmdline-compat.xml"; // NOI18N
   12.16 +    private static final String VCS_CVS_COMPAT_CODE_NAME_BASE = "org.netbeans.modules.vcs.cmdline.compat"; // NOI18N
   12.17      private static final String PARAM_ENABLED = "<param name=\"enabled\">"; // NOI18N
   12.18  
   12.19      static final long serialVersionUID =-3513549434587273290L;
   12.20 @@ -42,10 +45,19 @@
   12.21      public CvsModuleInstall() {
   12.22      }
   12.23  
   12.24 +    public void validate() throws IllegalStateException {
   12.25 +        if (isVcsCvsCompatInstalled()) {
   12.26 +            setEnabledCompat(false);
   12.27 +            waitForVcsCvsCompatToUninstall();
   12.28 +        }
   12.29 +    }
   12.30 +    
   12.31 +    /*
   12.32      public void installed() {
   12.33          setEnabledCompat(false);
   12.34          restored();
   12.35      }
   12.36 +     */
   12.37      
   12.38      public void uninstalled() {
   12.39          if (isVcsGenericInstalled()) {
   12.40 @@ -69,6 +81,36 @@
   12.41          return false;
   12.42      }
   12.43      
   12.44 +    private boolean isVcsCvsCompatInstalled() {
   12.45 +        Lookup.Result modules = Lookup.getDefault().lookup(new Lookup.Template(ModuleInfo.class));
   12.46 +        Collection moduleInfos = modules.allInstances();
   12.47 +        for (Iterator it = moduleInfos.iterator(); it.hasNext(); ) {
   12.48 +            ModuleInfo info = (ModuleInfo) it.next();
   12.49 +            if (VCS_CVS_COMPAT_CODE_NAME_BASE.equals(info.getCodeNameBase())) {
   12.50 +                return info.isEnabled();
   12.51 +            }
   12.52 +        }
   12.53 +        return false;
   12.54 +    }
   12.55 +    
   12.56 +    private synchronized void reCheckVcsCvsCompatInstall() {
   12.57 +        notify();
   12.58 +    }
   12.59 +    
   12.60 +    private synchronized void waitForVcsCvsCompatToUninstall() {
   12.61 +        Lookup.Result modules = Lookup.getDefault().lookup(new Lookup.Template(ModuleInfo.class));
   12.62 +        modules.addLookupListener(new LookupListener() {
   12.63 +            public void resultChanged(LookupEvent evt) {
   12.64 +                reCheckVcsCvsCompatInstall();
   12.65 +            }
   12.66 +        });
   12.67 +        while (!isVcsCvsCompatInstalled()) {
   12.68 +            try {
   12.69 +                wait();
   12.70 +            } catch (InterruptedException intrExc) {}
   12.71 +        }
   12.72 +    }
   12.73 +    
   12.74      private void setEnabledCompat(boolean enabled) {
   12.75          FileObject modules = TopManager.getDefault().getRepository().getDefaultFileSystem().findResource("Modules"); // NOI18N
   12.76          FileObject compatModule = modules.getFileObject(VCS_CVS_COMPAT_MODULE_FILE);
   12.77 @@ -80,7 +122,7 @@
   12.78              reader = new BufferedReader(new InputStreamReader(compatModule.getInputStream()));
   12.79              String line;
   12.80              while ((line = reader.readLine()) != null) {
   12.81 -                moduleXmlContent.append(line);
   12.82 +                moduleXmlContent.append(line+"\n");
   12.83              }
   12.84          } catch (IOException ioExc) {
   12.85              success = false;
    13.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/list/CvsListCommand.java	Tue Oct 16 16:26:42 2001 +0000
    13.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/list/CvsListCommand.java	Wed Oct 17 12:53:34 2001 +0000
    13.3 @@ -147,7 +147,13 @@
    13.4          //ec.addOutputListener(stdoutNRListener);
    13.5          ec.addErrorOutputListener(stderrNRListener);
    13.6          fileSystem.getCommandsPool().startExecutor(ec);
    13.7 -        fileSystem.getCommandsPool().waitToFinish(ec);
    13.8 +        try {
    13.9 +            fileSystem.getCommandsPool().waitToFinish(ec);
   13.10 +        } catch (InterruptedException iexc) {
   13.11 +            fileSystem.getCommandsPool().kill(ec);
   13.12 +            shouldFail = true;
   13.13 +            return ;
   13.14 +        }
   13.15          if (ec.getExitStatus() != VcsCommandExecutor.SUCCEEDED) {
   13.16              //E.err("exec failed "+ec.getExitStatus());
   13.17              shouldFail=true;
    14.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/list/CvsListRecursiveCommand.java	Tue Oct 16 16:26:42 2001 +0000
    14.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/list/CvsListRecursiveCommand.java	Wed Oct 17 12:53:34 2001 +0000
    14.3 @@ -215,7 +215,13 @@
    14.4          //ec.addOutputListener(stdoutNRListener);
    14.5          ec.addErrorOutputListener(stderrNRListener);
    14.6          fileSystem.getCommandsPool().startExecutor(ec);
    14.7 -        fileSystem.getCommandsPool().waitToFinish(ec);
    14.8 +        try {
    14.9 +            fileSystem.getCommandsPool().waitToFinish(ec);
   14.10 +        } catch (InterruptedException iexc) {
   14.11 +            fileSystem.getCommandsPool().kill(ec);
   14.12 +            shouldFail = true;
   14.13 +            return ;
   14.14 +        }
   14.15          if (ec.getExitStatus() != VcsCommandExecutor.SUCCEEDED) {
   14.16              //E.err("exec failed "+ec.getExitStatus());
   14.17              shouldFail = true;
    15.1 --- a/vcscvs/src/org/netbeans/modules/vcs/cmdline/passwd/CVSPasswd.java	Tue Oct 16 16:26:42 2001 +0000
    15.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/passwd/CVSPasswd.java	Wed Oct 17 12:53:34 2001 +0000
    15.3 @@ -300,7 +300,12 @@
    15.4              }
    15.5          });
    15.6          fs.getCommandsPool().startExecutor(vce);
    15.7 -        fs.getCommandsPool().waitToFinish(vce);
    15.8 +        try {
    15.9 +            fs.getCommandsPool().waitToFinish(vce);
   15.10 +        } catch (InterruptedException iexc) {
   15.11 +            fs.getCommandsPool().kill(vce);
   15.12 +            return false;
   15.13 +        }
   15.14          if (vce.getExitStatus() == VcsCommandExecutor.SUCCEEDED) return true;
   15.15          String output = loginCommandOutput.toString().trim();
   15.16          message.delete(0, message.length());