Package org.tmatesoft.hg.core

Examples of org.tmatesoft.hg.core.HgBadArgumentException


      String server = null;
      if (hgRepo != null && !hgRepo.isInvalid()) {
        PathsSection ps = hgRepo.getConfiguration().getPaths();
        server = key == null || key.trim().length() == 0 ? ps.getDefault() : ps.getString(key, null); // XXX Java 1.5 isEmpty()
      } else if (key == null || key.trim().length() == 0) {
        throw new HgBadArgumentException("Can't look up empty key in a global configuration", null);
      }
      if (server == null) {
        server = getGlobalConfig().getSection("paths").get(key);
      }
      if (server == null) {
        throw new HgBadArgumentException(String.format("Can't find server %s specification in the config", key), toReport);
      }
      try {
        uri = new URI(server);
      } catch (URISyntaxException ex) {
        throw new HgBadArgumentException(String.format("Found %s server spec in the config, but failed to initialize with it", key), ex);
      }
    }
    return detectRemote(uri);
  }
View Full Code Here


      throw new IllegalArgumentException();
    }
    try {
      return detectRemote(url.toURI());
    } catch (URISyntaxException ex) {
      throw new HgBadArgumentException(String.format("Bad remote repository location: %s", url), ex);
    }
  }
View Full Code Here

   * @throws HgBadArgumentException
   */
  public HgRemoteRepository detectRemote(URI uriRemote) throws HgBadArgumentException {
    HgRemoteRepository.RemoteDescriptor rd = getSessionContext().getRemoteDescriptor(uriRemote);
    if (rd == null) {
      throw new HgBadArgumentException(String.format("Unsupported remote repository location:%s", uriRemote), null);
    }
    return new HgRemoteRepository(getSessionContext(), rd);
  }
View Full Code Here

  }

  public Connector createConnector() throws HgBadArgumentException {
    Pair<ClassLoader, String> connectorToBe = connFactory.get(uri.getScheme());
    if (connectorToBe == null || connectorToBe.second() == null) {
      throw new HgBadArgumentException(String.format("Can't instantiate connector for scheme '%s'", uri.getScheme()), null);
    }
    try {
      Class<?> connClass = connectorToBe.first().loadClass(connectorToBe.second());
      if (!Connector.class.isAssignableFrom(connClass)) {
        throw new HgBadArgumentException(String.format("Connector %s for scheme '%s' is not a subclass of %s", connectorToBe.second(), uri.getScheme(), Connector.class.getName()), null);
      }
      final Object connector = connClass.newInstance();
      return Connector.class.cast(connector);
    } catch (ClassNotFoundException ex) {
      throw new HgBadArgumentException(String.format("Can't instantiate connector %s for scheme '%s'", connectorToBe.second(), uri.getScheme()), ex);
    } catch (InstantiationException ex) {
      throw new HgBadArgumentException(String.format("Can't instantiate connector %s for scheme '%s'", connectorToBe.second(), uri.getScheme()), ex);
    } catch (IllegalAccessException ex) {
      throw new HgBadArgumentException(String.format("Can't instantiate connector %s for scheme '%s'", connectorToBe.second(), uri.getScheme()), ex);
    }
  }
View Full Code Here

 
  public CsetParamKeeper set(Nodeid changeset) throws HgBadArgumentException {
    try {
      set(repo.getChangelog().getRevisionIndex(changeset));
    } catch (HgInvalidRevisionException ex) {
      throw new HgBadArgumentException("Can't find revision", ex).setRevision(changeset);
    } catch (HgRuntimeException ex) {
      throw new HgBadArgumentException(String.format("Can't initialize with revision %s", changeset.shortNotation()), ex);
    }
    return this;
  }
View Full Code Here

      int lastCsetIndex = repo.getChangelog().getLastRevision();
      if (changelogRevIndex == HgRepository.TIP) {
        changelogRevIndex = lastCsetIndex;
      }
      if (changelogRevIndex < 0 || changelogRevIndex > lastCsetIndex) {
        throw new HgBadArgumentException(String.format("Bad revision index %d, value from [0..%d] expected", changelogRevIndex, lastCsetIndex), null).setRevisionIndex(changelogRevIndex);
      }
      doSet(changelogRevIndex);
    } catch (HgRuntimeException ex) {
      throw new HgBadArgumentException(String.format("Can't initialize with revision index %d", changelogRevIndex), ex);
    }
    return this;
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.core.HgBadArgumentException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.