DebugLog.log("driver: last path: " + lastPath); DebugLog.log("driver: common ancestor: " + commonAncestor);
    public static void driveCommitEditor(ISVNCommitPathHandler handler,            Collection paths, ISVNEditor editor, long revision)            throws SVNException {        if (paths == null || paths.isEmpty() || handler == null                || editor == null) {            return;        }        String[] pathsArray = (String[]) paths                .toArray(new String[paths.size()]);        Arrays.sort(pathsArray);        int index = 0;        String lastPath = null;        if ("".equals(pathsArray[index])) {            handler.handleCommitPath("", editor);            lastPath = pathsArray[index];            index++;        } else {            editor.openRoot(revision);        }        DebugLog.log("driver: paths count: " + pathsArray.length);        for (int i = 0; i < pathsArray.length; i++) {            DebugLog.log("driver: commit path: " + pathsArray[i]);        }        for (; index < pathsArray.length; index++) {            String commitPath = pathsArray[index];            DebugLog.log("driver: processing path: " + commitPath);            String commonAncestor = lastPath == null || "".equals(lastPath) ? ""                     : SVNPathUtil.getCommonPathAncestor(commitPath, lastPath);            if (lastPath != null) {                while (!lastPath.equals(commonAncestor)) {                    editor.closeDir();                    if (lastPath.lastIndexOf('/') >= 0) {                        lastPath = lastPath.substring(0, lastPath                                .lastIndexOf('/'));                    } else {                        lastPath = "";                    }                }            }            DebugLog.log("driver: last path: " + lastPath);            DebugLog.log("driver: common ancestor: " + commonAncestor);            String relativeCommitPath = commitPath.substring(commonAncestor                    .length());            if (relativeCommitPath.startsWith("/")) {                relativeCommitPath = relativeCommitPath.substring(1);            }            DebugLog.log("driver: relative commit path: " + relativeCommitPath);            for (StringTokenizer tokens = new StringTokenizer(                    relativeCommitPath, "/"); tokens.hasMoreTokens();) {                String token = tokens.nextToken();                commonAncestor = "".equals(commonAncestor) ? token                        : commonAncestor + "/" + token;                if (!commonAncestor.equals(commitPath)) {                    DebugLog.log("driver: open dir: " + commonAncestor);                    editor.openDir(commonAncestor, revision);                } else {                    break;                }            }            boolean closeDir = handler.handleCommitPath(commitPath, editor);            if (closeDir) {                lastPath = commitPath;            } else {                lastPath = PathUtil.removeTail(commitPath);                if (PathUtil.isEmpty(lastPath)) {                    lastPath = "";                }            }            DebugLog.log("driver: last open path: " + lastPath);        }        while (lastPath != null && !"".equals(lastPath)) {            editor.closeDir();            lastPath = lastPath.lastIndexOf('/') >= 0 ? lastPath.substring(0,                    lastPath.lastIndexOf('/')) : "";        }    }