resultFile.delete();
if (resultFile != null) { resultFile.delete(); }
    public SVNStatusType mergeText(String localPath, String basePath, String latestPath, String localLabel, String baseLabel, String latestLabel, boolean dryRun) throws SVNException {        String mimeType = getProperties(localPath, false).getPropertyValue(SVNProperty.MIME_TYPE);        SVNEntry entry = getEntries().getEntry(localPath, true);        if (mimeType != null && !mimeType.startsWith("text/")) {            // binary            if (!dryRun) {                File oldFile = SVNFileUtil.createUniqueFile(getRoot(), localPath, baseLabel);                 File newFile = SVNFileUtil.createUniqueFile(getRoot(), localPath, latestLabel);                 try {                    SVNFileUtil.copy(getFile(basePath, false), oldFile, false);                    SVNFileUtil.copy(getFile(latestPath, false), newFile, false);                } catch (IOException e) {                    SVNErrorManager.error(0, e);                }                // update entry props                entry.setConflictNew(SVNFileUtil.getBasePath(newFile));                entry.setConflictOld(SVNFileUtil.getBasePath(oldFile));                entry.setConflictWorking(null);                            }            return SVNStatusType.CONFLICTED;        }        // text        // 1. destranslate local        File localTmpFile = SVNFileUtil.createUniqueFile(getRoot(), localPath, ".tmp");        SVNTranslator.translate(this, localPath, localPath, SVNFileUtil.getBasePath(localTmpFile), false, false);        // 2. run merge between all files we have :)        RandomAccessFile localIS = null;        RandomAccessFile latestIS = null;        RandomAccessFile baseIS = null;        OutputStream result = null;        File resultFile = dryRun ? null : SVNFileUtil.createUniqueFile(getRoot(), localPath, ".result");                byte[] conflictStart = ("<<<<<<< " + localLabel).getBytes();         byte[] conflictEnd = (">>>>>>> " + latestLabel).getBytes();        byte[] separator = ("=======").getBytes();        FSMergerBySequence merger = new FSMergerBySequence(conflictStart, separator, conflictEnd, null);        int mergeResult = 0;        try {            localIS = new RandomAccessFile(localTmpFile, "r");            latestIS = new RandomAccessFile(getFile(latestPath, false), "r");            baseIS = new RandomAccessFile(getFile(basePath, false), "r");            OutputStream dummy = new OutputStream() {                public void write(int b) throws IOException {}            };            result = resultFile == null ?  dummy : new FileOutputStream(resultFile);                        QSequenceLineRAData baseData = new QSequenceLineRAFileData(baseIS);            QSequenceLineRAData localData = new QSequenceLineRAFileData(localIS);            QSequenceLineRAData latestData = new QSequenceLineRAFileData(latestIS);            debugQData("base  :\n", baseData);            debugQData("local :\n", localData);            debugQData("latest:\n", latestData);            mergeResult = merger.merge(baseData, localData, latestData, result);            DebugLog.log("merge result: " + mergeResult);        } catch (IOException e) {            SVNErrorManager.error(0, e);        } finally {            try {                result.close();                localIS.close();                baseIS.close();                latestIS.close();            } catch (IOException e) {}        }        SVNStatusType status = SVNStatusType.UNCHANGED;        if (mergeResult == 2) {            status = SVNStatusType.CONFLICTED;        } else if (mergeResult == 4) {            status = SVNStatusType.MERGED;        }        if (dryRun) {            localTmpFile.delete();            return status;        }        if (status != SVNStatusType.CONFLICTED) {            SVNTranslator.translate(this, localPath, SVNFileUtil.getBasePath(resultFile), localPath, true, true);        } else {            // copy all to wc.            File mineFile = SVNFileUtil.createUniqueFile(getRoot(), localPath, localLabel);            String minePath = SVNFileUtil.getBasePath(mineFile);            try {                SVNFileUtil.copy(getFile(localPath, false), mineFile, false);            } catch (IOException e) {                SVNErrorManager.error(0, e);            }            File oldFile = SVNFileUtil.createUniqueFile(getRoot(), localPath, baseLabel);            String oldPath = SVNFileUtil.getBasePath(oldFile);            File newFile = SVNFileUtil.createUniqueFile(getRoot(), localPath, latestLabel);            String newPath = SVNFileUtil.getBasePath(newFile);            SVNTranslator.translate(this, localPath, basePath, oldPath, true, false);            SVNTranslator.translate(this, localPath, latestPath, newPath, true, false);            // translate result to local            SVNTranslator.translate(this, localPath, SVNFileUtil.getBasePath(resultFile), localPath, true, true);            entry.setConflictNew(newPath);            entry.setConflictOld(oldPath);            entry.setConflictWorking(minePath);                        }        localTmpFile.delete();        resultFile.delete();        return status;    }