path = PathUtil.removeLeadingSlash(path);
    public SVNExternalInfo[] addExternals(SVNDirectory directory, String externals) throws SVNException {        if (externals == null) {            return null;        }        Collection result = new ArrayList();        for(StringTokenizer lines = new StringTokenizer(externals, "\n\r"); lines.hasMoreTokens();) {            String line = lines.nextToken().trim();            if (line.length() == 0 || line.startsWith("#")) {                continue;            }            String url = null;            String path = null;            long rev = -1;            List parts = new ArrayList(4);             for(StringTokenizer tokens = new StringTokenizer(line, " \t"); tokens.hasMoreTokens();) {                String token = tokens.nextToken().trim();                parts.add(token);            }            if (parts.size() < 2) {                continue;            }            path = PathUtil.append(directory.getPath(), (String) parts.get(0));            path = PathUtil.removeLeadingSlash(path);            if (parts.size() == 2) {                url = (String) parts.get(1);            } else if (parts.size() == 3 && parts.get(1).toString().startsWith("-r")) {                String revStr = parts.get(1).toString();                revStr = revStr.substring("-r".length());                if (!"HEAD".equals(revStr)) {                    try {                        rev = Long.parseLong(revStr);                    } catch (NumberFormatException nfe) {                        continue;                    }                }                url = (String) parts.get(2);                            } else if (parts.size() == 4 && "-r".equals(parts.get(1))) {                String revStr = parts.get(2).toString();                if (!"HEAD".equals(revStr)) {                    try {                        rev = Long.parseLong(revStr);                    } catch (NumberFormatException nfe) {                        continue;                    }                }                url = (String) parts.get(4);                            }            if (path!= null && url != null) {                SVNExternalInfo info = addExternal(path, url, rev);                result.add(info);            }        }        return (SVNExternalInfo[]) result.toArray(new SVNExternalInfo[result.size()]);    }