コード例 #1
0
  /**
   * Gets a repo by its URL. If URL is unknown, returns a new location, adding it to the global
   * repositories cache. Will update stored last user and password with the provided values.
   */
  public IHgRepositoryLocation updateRepoLocation(
      HgRoot hgRoot, String url, String logicalName, String user, String pass) throws HgException {
    IHgRepositoryLocation loc = matchRepoLocation(url);

    if (loc == null) {
      // in some cases url may be a repository database line
      loc = HgRepositoryLocationParser.parseLocation(logicalName, url, user, pass);
      addRepoLocation(loc);
      return loc;
    }

    boolean update = false;

    String myLogicalName = logicalName;
    String myUser = user;
    String myPass = pass;

    if (logicalName != null
        && logicalName.length() > 0
        && !logicalName.equals(loc.getLogicalName())) {
      update = true;
    } else {
      myLogicalName = loc.getLogicalName();
    }
    if (user != null && user.length() > 0 && !user.equals(loc.getUser())) {
      update = true;
    } else {
      myUser = loc.getUser();
    }
    if (pass != null && pass.length() > 0 && !pass.equals(loc.getPassword())) {
      update = true;
    } else {
      myPass = loc.getPassword();
    }

    if (update) {
      IHgRepositoryLocation updated =
          HgRepositoryLocationParser.parseLocation(
              myLogicalName, loc.getLocation(), myUser, myPass);

      synchronized (entriesLock) {
        for (Set<IHgRepositoryLocation> locs : rootRepos.values()) {
          if (locs.remove(updated)) {
            locs.add(updated);
          }
        }
      }
      synchronized (repoHistory) {
        if (repoHistory.remove(updated)) {
          repoHistory.add(updated);
        }
      }
      repositoryModified(updated);
      return updated;
    }

    return loc;
  }
コード例 #2
0
  /**
   * Get a repo specified by properties. If repository for given url is unknown, returns a new
   * location.
   *
   * @return never returns null
   */
  public IHgRepositoryLocation getRepoLocation(Properties props) throws HgException {
    String user = props.getProperty("user"); // $NON-NLS-1$
    if ((user == null) || (user.length() == 0)) {
      user = null;
    }
    String password = props.getProperty("password"); // $NON-NLS-1$
    if (user == null) {
      password = null;
    }
    String url = props.getProperty("url"); // $NON-NLS-1$
    if (url == null) {
      throw new HgException(
          Messages.getString("HgRepositoryLocation.urlMustNotBeNull")); // $NON-NLS-1$
    }

    IHgRepositoryLocation location = matchRepoLocation(url);
    if (location != null) {
      if (user == null
          || user.length() == 0
          || (user.equals(location.getUser())
              && (password == null || password.equals(location.getPassword())))) {
        return location;
      }
    }

    // make a new location if no matches exist or it's a different user
    return HgRepositoryLocationParser.parseLocation(url, user, password);
  }
コード例 #3
0
  /**
   * Get a repo by its URL. If URL is unknown, returns a new location.
   *
   * @return never returns null
   */
  public IHgRepositoryLocation getRepoLocation(String url, String user, String pass)
      throws HgException {
    getProjectRepos();
    IHgRepositoryLocation location = matchRepoLocation(url);
    if (location != null) {
      if (user == null
          || user.length() == 0
          || (user.equals(location.getUser())
              && (pass == null || pass.equals(location.getPassword())))) {
        return location;
      }
    }

    // make a new location if no matches exist or it's a different user
    return HgRepositoryLocationParser.parseLocation(url, user, pass);
  }