SVNCommitPacket commitPacket = null; Collection tmpFiles = null; SVNCommitInfo info = null; ISVNEditor commitEditor = null; try { commitPacket = doCollectCommitItems(paths, keepLocks, recursive); if (commitPacket == null || commitPacket == SVNCommitPacket.EMPTY) { return -1; } System.out.println(commitPacket); commitMessage = getCommitHandler().getCommitMessage(commitMessage, commitPacket.getCommitItems()); if (commitMessage == null) { return -1; } Map commitables = new TreeMap(); String baseURL = SVNCommitUtil.translateCommitables(commitPacket.getCommitItems(), commitables); System.out.println("base URL: " + baseURL); Map lockTokens = SVNCommitUtil.translateLockTokens(commitPacket.getLockTokens(), baseURL);  SVNRepository repository = createRepository(baseURL); SVNCommitMediator mediator = new SVNCommitMediator(commitPacket.getWCAccess(), commitables); tmpFiles = mediator.getTmpFiles(); commitEditor = repository.getCommitEditor(commitMessage, lockTokens, keepLocks, mediator);  info = commit(commitPacket.getWCAccess(), mediator.getTmpFiles(), commitables, commitEditor);  SVNWCAccess wcAccess = commitPacket.getWCAccess(); Collection processedItems = new HashSet(); for (Iterator urls = commitables.keySet().iterator(); urls.hasNext();) { String url = (String) urls.next(); SVNCommitItem item = (SVNCommitItem) commitables.get(url); String path = item.getPath(); SVNDirectory dir; String target;  if (item.getKind() == SVNNodeKind.DIR) { dir = wcAccess.getDirectory(path); target = ""; } else { dir = wcAccess.getDirectory(PathUtil.removeTail(path)); target = PathUtil.tail(path); } if (dir == null) { if (hasProcessedParents(processedItems, path)) { processedItems.add(path); continue; } if (item.isDeleted() && item.getKind() == SVNNodeKind.DIR) { String parentPath = "".equals(path) ? null : PathUtil.removeTail(path); String nameInParent = "".equals(path) ? null : PathUtil.tail(path); if (parentPath != null) { SVNDirectory parentDir = wcAccess.getDirectory(parentPath); if (parentDir != null) { SVNEntry entryInParent = parentDir.getEntries().getEntry(nameInParent, true); if (entryInParent != null) { entryInParent.unschedule(); entryInParent.setDeleted(true); parentDir.getEntries().save(false); } } } processedItems.add(path); continue; }  } SVNEntry entry = dir.getEntries().getEntry(target, true); if (entry == null && hasProcessedParents(processedItems, path)) { processedItems.add(path); continue; } boolean recurse = false; if (item.isAdded() && item.getCopyFromURL() != null && item.getKind() == SVNNodeKind.DIR) { recurse = true; } boolean removeLock = !keepLocks && item.isLocked();  Map wcPropChanges = mediator.getWCProperties(item); dir.commit(target, info, wcPropChanges, removeLock,  recursive); } } finally { if (info == null && commitEditor != null) { try { commitEditor.abortEdit(); } catch (SVNException e) {  } } if (tmpFiles != null) { for (Iterator files = tmpFiles.iterator(); files.hasNext();) { File file = (File) files.next(); file.delete(); } } if (commitPacket != null) { commitPacket.dispose(); } } return info != null ? info.getNewRevision() : -1;
SVNCommitPacket packet = doCollectCommitItems(paths, keepLocks, recursive); return doCommit(packet, keepLocks, commitMessage, recursive);
    public long doCommit(File[] paths, boolean keepLocks, String commitMessage, boolean recursive) throws SVNException {        SVNCommitPacket commitPacket = null;        Collection tmpFiles = null;        SVNCommitInfo info = null;        ISVNEditor commitEditor = null;        try {            commitPacket = doCollectCommitItems(paths, keepLocks, recursive);            if (commitPacket == null || commitPacket == SVNCommitPacket.EMPTY) {                return -1;            }            System.out.println(commitPacket);            commitMessage = getCommitHandler().getCommitMessage(commitMessage, commitPacket.getCommitItems());            if (commitMessage == null) {                return -1;            }            Map commitables = new TreeMap();            String baseURL = SVNCommitUtil.translateCommitables(commitPacket.getCommitItems(), commitables);            System.out.println("base URL: " + baseURL);            Map lockTokens = SVNCommitUtil.translateLockTokens(commitPacket.getLockTokens(), baseURL);            SVNRepository repository = createRepository(baseURL);            SVNCommitMediator mediator = new SVNCommitMediator(commitPacket.getWCAccess(), commitables);            tmpFiles = mediator.getTmpFiles();            commitEditor = repository.getCommitEditor(commitMessage, lockTokens, keepLocks, mediator);            // commit.            info = commit(commitPacket.getWCAccess(), mediator.getTmpFiles(), commitables, commitEditor);            // update wc.            SVNWCAccess wcAccess = commitPacket.getWCAccess();            Collection processedItems = new HashSet();            for (Iterator urls = commitables.keySet().iterator(); urls.hasNext();) {                String url = (String) urls.next();                SVNCommitItem item = (SVNCommitItem) commitables.get(url);                String path = item.getPath();                SVNDirectory dir;                String target;                if (item.getKind() == SVNNodeKind.DIR) {                    dir = wcAccess.getDirectory(path);                    target = "";                } else {                    dir = wcAccess.getDirectory(PathUtil.removeTail(path));                    target = PathUtil.tail(path);                }                if (dir == null) {                    if (hasProcessedParents(processedItems, path)) {                        processedItems.add(path);                        continue;                    }                    if (item.isDeleted() && item.getKind() == SVNNodeKind.DIR) {                        String parentPath = "".equals(path) ? null : PathUtil.removeTail(path);                        String nameInParent = "".equals(path) ? null : PathUtil.tail(path);                        if (parentPath != null) {                            SVNDirectory parentDir = wcAccess.getDirectory(parentPath);                            if (parentDir != null) {                                SVNEntry entryInParent = parentDir.getEntries().getEntry(nameInParent, true);                                if (entryInParent != null) {                                    entryInParent.unschedule();                                    entryInParent.setDeleted(true);                                    parentDir.getEntries().save(false);                                }                            }                        }                        processedItems.add(path);                        continue;                    }                }                SVNEntry entry = dir.getEntries().getEntry(target, true);                if (entry == null && hasProcessedParents(processedItems, path)) {                    processedItems.add(path);                    continue;                }                boolean recurse = false;                if (item.isAdded() && item.getCopyFromURL() != null && item.getKind() == SVNNodeKind.DIR) {                    recurse = true;                }                boolean removeLock = !keepLocks && item.isLocked();                // update entry in dir.                Map wcPropChanges = mediator.getWCProperties(item);                dir.commit(target, info, wcPropChanges, removeLock,  recursive);            }        } finally {            if (info == null && commitEditor != null) {                try {                    commitEditor.abortEdit();                } catch (SVNException e) {                    //                }            }            if (tmpFiles != null) {                for (Iterator files = tmpFiles.iterator(); files.hasNext();) {                    File file = (File) files.next();                    file.delete();                }            }            if (commitPacket != null) {                commitPacket.dispose();            }        }        return info != null ? info.getNewRevision() : -1;    }