  public Settings(VcsRoot root) throws VcsException {
    final String p = root.getProperty(Constants.PATH);
    repositoryPath = p == null ? null : new File(p);
    branch = root.getProperty(Constants.BRANCH_NAME);
    String username = root.getProperty(Constants.USERNAME);
    String password = root.getProperty(Constants.PASSWORD);
    final String remote = root.getProperty(Constants.URL);
    URIish uri;
    try {
      uri = new URIish(remote);
    } catch (URISyntaxException e) {
      throw new VcsException("Invalid URI: " + remote);
    }
    if (!StringUtil.isEmptyOrSpaces(username)) {
      uri.setUser(username);
    }
    if (!StringUtil.isEmpty(password)) {
      uri.setUser(password);
    }
    publicURL = uri.toString();
    repositoryURL = uri.toPrivateString();
    final String style = root.getProperty(Constants.USERNAME_STYLE);
    usernameStyle = style == null ? UserNameStyle.USERID : Enum.valueOf(UserNameStyle.class, style);
  }

  public Settings(VcsRoot root) throws VcsException {
    final String p = root.getProperty(Constants.PATH);
    repositoryPath = p == null ? null : new File(p);
    branch = root.getProperty(Constants.BRANCH_NAME);
    String username = root.getProperty(Constants.USERNAME);
    String password = root.getProperty(Constants.PASSWORD);
    final String remote = root.getProperty(Constants.URL);
    URIish uri;
    try {
      uri = new URIish(remote);
    } catch (URISyntaxException e) {
      throw new VcsException("Invalid URI: " + remote);
    }
    if (!StringUtil.isEmptyOrSpaces(username)) {
      uri = uri.setUser(username);
    }
    if (!StringUtil.isEmpty(password)) {
      uri = uri.setPass(password);
    }
    publicURL = uri.toString();
    repositoryURL = uri.toPrivateString();
    final String style = root.getProperty(Constants.USERNAME_STYLE);
    usernameStyle = style == null ? UserNameStyle.USERID : Enum.valueOf(UserNameStyle.class, style);
  }
