Examples of SVNMergeFileSet


Examples of org.tmatesoft.svn.core.wc.SVNMergeFileSet

            String mimeType = null;
            if (!isDir && workingProps != null) {
                mimeType = workingProps.getStringValue(SVNProperty.MIME_TYPE);
            }
            SVNMergeFileSet fileSet = new SVNMergeFileSet(adminArea, log, baseFile, workingFile, localPath,
                    newFile, mergedFile, null, mimeType);

            SVNConflictAction action = SVNConflictAction.EDIT;
            if (oldValue == null && newValue != null) {
                action = SVNConflictAction.ADD;
View Full Code Here

Examples of org.tmatesoft.svn.core.wc.SVNMergeFileSet

       
        File tmpTarget = SVNTranslator.detranslateWorkingCopy(this, workingText, propChanges, false);
        base = SVNTranslator.maybeUpdateTargetEOLs(this, base, propChanges);
        File resultFile = SVNAdminUtil.createTmpFile(this);

        SVNMergeFileSet mergeFileSet = new SVNMergeFileSet(this, log, base, tmpTarget, localPath, latest,
                resultFile, copyFromText, mimeType);

        mergeFileSet.setMergeLabels(baseLabel, localLabel, latestLabel);

      SVNMergeResult mergeResult;
      try {
          mergeResult = merger.mergeText(mergeFileSet, dryRun, options);
      }
      finally {
        if (dryRun) {
            SVNFileUtil.deleteFile(resultFile);
        }
      }
        mergeFileSet.dispose();

        if (saveLog) {
            log.save();
        }
View Full Code Here

Examples of org.tmatesoft.svn.core.wc.SVNMergeFileSet

    public SVNConflictResult handleConflict(SVNConflictDescription conflictDescription) throws SVNException {
        if (conflictDescription.isTreeConflict()) {
// TODO: SVNKit 1.3          
            return null;
        }
        SVNMergeFileSet files = conflictDescription.getMergeFiles();
        if (myAccept == SVNConflictAcceptPolicy.POSTPONE) {
            return new SVNConflictResult(SVNConflictChoice.POSTPONE, null);
        } else if (myAccept == SVNConflictAcceptPolicy.BASE) {
            return new SVNConflictResult(SVNConflictChoice.BASE, null);
        } else if (myAccept == SVNConflictAcceptPolicy.MINE) {
            return new SVNConflictResult(SVNConflictChoice.MINE_CONFLICT, null);
        } else if (myAccept == SVNConflictAcceptPolicy.THEIRS) {
            return new SVNConflictResult(SVNConflictChoice.THEIRS_CONFLICT, null);
        } else if (myAccept == SVNConflictAcceptPolicy.MINE_FULL) {
            return new SVNConflictResult(SVNConflictChoice.MINE_FULL, null);
        } else if (myAccept == SVNConflictAcceptPolicy.THEIRS_FULL) {
            return new SVNConflictResult(SVNConflictChoice.THEIRS_FULL, null);
        } else if (myAccept == SVNConflictAcceptPolicy.EDIT) {
            if (files.getResultFile() != null) {
                if (myIsExternalFailed) {
                    return new SVNConflictResult(SVNConflictChoice.POSTPONE, null);
                }
               
                try {
                    SVNCommandUtil.editFileExternally(mySVNEnvironment, mySVNEnvironment.getEditorCommand(),
                            files.getResultFile().getAbsolutePath());
                } catch (SVNException svne) {
                    if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.CL_NO_EXTERNAL_EDITOR) {
                        mySVNEnvironment.getErr().println(svne.getErrorMessage().getMessage() != null ?
                                svne.getErrorMessage().getMessage() : "No editor found, leaving all conflicts.");
                        myIsExternalFailed = true;
                    } else if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.EXTERNAL_PROGRAM) {
                        mySVNEnvironment.getErr().println(svne.getErrorMessage().getMessage() != null ?
                                svne.getErrorMessage().getMessage() : "Error running editor, leaving all conflicts.");
                        myIsExternalFailed = true;
                    } else {
                        throw svne;
                    }
                }
                return new SVNConflictResult(SVNConflictChoice.MERGED, null);
            }
        } else if (myAccept == SVNConflictAcceptPolicy.LAUNCH) {
            if (files.getBaseFile() != null && files.getLocalFile() != null && files.getRepositoryFile() != null &&
                    files.getResultFile() != null) {
                if (myIsExternalFailed) {
                    return new SVNConflictResult(SVNConflictChoice.POSTPONE, null);
                }
               
                try {
                    SVNCommandUtil.mergeFileExternally(mySVNEnvironment, files.getBaseFile().getAbsolutePath(),
                            files.getRepositoryFile().getAbsolutePath(),
                            files.getLocalFile().getAbsolutePath(),
                            files.getResultFile().getAbsolutePath());
                } catch (SVNException svne) {
                    if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.CL_NO_EXTERNAL_MERGE_TOOL) {
                        mySVNEnvironment.getErr().println(svne.getErrorMessage().getMessage() != null ?
                                svne.getErrorMessage().getMessage() : "No merge tool found.");
                        myIsExternalFailed = true;
                    } else if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.EXTERNAL_PROGRAM) {
                        mySVNEnvironment.getErr().println(svne.getErrorMessage().getMessage() != null ?
                                svne.getErrorMessage().getMessage() : "Error running merge tool.");
                        myIsExternalFailed = true;
                    } else {
                        throw svne;
                    }
                }
                return new SVNConflictResult(SVNConflictChoice.MERGED, null);
            }
        }
       
        SVNConflictChoice choice = SVNConflictChoice.POSTPONE;
        if ((conflictDescription.getNodeKind() == SVNNodeKind.FILE &&
                conflictDescription.getConflictAction() == SVNConflictAction.EDIT &&
                conflictDescription.getConflictReason() == SVNConflictReason.EDITED) ||
                conflictDescription.isPropertyConflict()) {
           
            boolean performedEdit = false;
            boolean diffAllowed = false;
            String path = mySVNEnvironment.getRelativePath(files.getWCFile());
            path = SVNCommandUtil.getLocalPath(path);

            if (conflictDescription.isPropertyConflict()) {
                String message = "Property conflict for ''{0}'' discovered on ''{1}''.";
                message = MessageFormat.format(message, new Object[] { conflictDescription.getPropertyName(),
                        path });
                mySVNEnvironment.getErr().println(message);
               
                if ((files.getLocalFile() == null && files.getRepositoryFile() != null) ||
                        (files.getLocalFile() != null && files.getRepositoryFile() == null)) {
                    if (files.getLocalFile() != null) {
                        String myVal = SVNFileUtil.readFile(files.getLocalFile());
                        message = MessageFormat.format("They want to delete the property, you want to change the value to ''{0}''.",
                                new Object[] { myVal });
                        mySVNEnvironment.getErr().println(message);
                    }
                } else {
                    String reposVal = SVNFileUtil.readFile(files.getRepositoryFile());
                    message = MessageFormat.format("They want to change the property value to ''{0}'', you want to delete the property.",
                            new Object[] { reposVal });
                    mySVNEnvironment.getErr().println(message);
                }
            } else {
                String message = "Conflict discovered in ''{0}''.";
                message = MessageFormat.format(message, new Object[] { path });
                mySVNEnvironment.getErr().println(message);
            }
           
            if ((files.getResultFile() != null && files.getBaseFile() != null) || (files.getBaseFile() != null &&
                    files.getLocalFile() != null && files.getRepositoryFile() != null)) {
                diffAllowed = true;
            }
           
            while (true) {
                String message = "Select: (p)ostpone";
                if (diffAllowed) {
                    message += ", (D)iff in full, (e)dit";
                } else {
                    message += ", (M)ine in full, (T)heirs in full";
                }
                if (performedEdit) {
                    message += ", (r)esolved";
                }
                if (!diffAllowed && performedEdit) {
                    message += ",\n        ";
                } else {
                    message += ", ";
                }
                message += "(h)elp for more options : ";
                String answer = SVNCommandUtil.prompt(message, mySVNEnvironment);
                char answerChar = '\0';
                if (answer != null) {
                    if (answer.length() == 1) {
                        answerChar = answer.charAt(0);
                    } else {
                        continue;
                    }
                }
                if (answerChar == 'h' || answerChar == '?') {
                    mySVNEnvironment.getErr().println("  (p)ostpone    - mark the conflict to be resolved later");
                    mySVNEnvironment.getErr().println("  (D)iff-full   - show all changes made to merged file");
                    mySVNEnvironment.getErr().println("  (e)dit        - change merged file in an editor");
                    mySVNEnvironment.getErr().println("  (r)esolved    - accept merged version of file");
                    mySVNEnvironment.getErr().println("  (M)ine-full   - accept my version of entire file (ignore their changes)");
                    mySVNEnvironment.getErr().println("  (T)heirs-full - accept their version of entire file (lose my changes)");
                    mySVNEnvironment.getErr().println("  (l)aunch      - use third-party tool to resolve conflict");
                    mySVNEnvironment.getErr().println("  (h)elp        - show this list");
                    mySVNEnvironment.getErr().println();
                } else  if (answerChar == 'p') {
                    choice = SVNConflictChoice.POSTPONE;
                    break;
                } else if (answerChar == 'm') {
                    //choice = SVNConflictChoice.MINE;
                    //break;
                    mySVNEnvironment.getErr().println("Sorry, '(m)ine' is not yet implemented; see");
                    mySVNEnvironment.getErr().println("http://subversion.tigris.org/issues/show_bug.cgi?id=3049");
                    mySVNEnvironment.getErr().println();
                    continue;
                } else if (answerChar == 't') {
                    //choice = SVNConflictChoice.THEIRS;
                    //break;
                    mySVNEnvironment.getErr().println("Sorry, '(t)heirs' is not yet implemented; see");
                    mySVNEnvironment.getErr().println("http://subversion.tigris.org/issues/show_bug.cgi?id=3049");
                    mySVNEnvironment.getErr().println();
                    continue;
                } else if (answerChar == 'M') {
                    choice = SVNConflictChoice.MINE_FULL;
                    break;
                } else if (answerChar == 'T') {
                    choice = SVNConflictChoice.THEIRS_FULL;
                    break;
                } else if (answerChar == 'd') {
                    mySVNEnvironment.getErr().println("Sorry, '(d)iff' is not yet implemented; see");
                    mySVNEnvironment.getErr().println("http://subversion.tigris.org/issues/show_bug.cgi?id=3048");
                    mySVNEnvironment.getErr().println();
                    continue;
                } else if (answerChar == 'D') {
                    if (!diffAllowed) {
                        mySVNEnvironment.getErr().println("Invalid option; there's no merged version to diff.");
                        mySVNEnvironment.getErr().println();
                        continue;
                    }
                   
                    File path1 = null;
                    File path2 = null;
                    if (files.getResultFile() != null && files.getBaseFile() != null) {
                        path1 = files.getBaseFile();
                        path2 = files.getResultFile();
                    } else {
                        path1 = files.getRepositoryFile();
                        path2 = files.getLocalFile();
                    }
                   
                    DefaultSVNCommandLineDiffGenerator diffGenerator = new DefaultSVNCommandLineDiffGenerator(path1, path2);
                    diffGenerator.setDiffOptions(new SVNDiffOptions(false, false, true));
                    diffGenerator.displayFileDiff("", path1, path2, null, null, null, null, System.out);
                    performedEdit = true;
                } else if (answerChar == 'e') {
                    if (files.getResultFile() != null) {
                        try {
                            String resultPath = files.getResultFile().getAbsolutePath();
                            SVNCommandUtil.editFileExternally(mySVNEnvironment, mySVNEnvironment.getEditorCommand(),
                                    resultPath);
                            performedEdit = true;
                        } catch (SVNException svne) {
                            if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.CL_NO_EXTERNAL_EDITOR) {
                                mySVNEnvironment.getErr().println(svne.getErrorMessage().getMessage() != null ?
                                        svne.getErrorMessage().getMessage() : "No editor found.");
                            } else if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.EXTERNAL_PROGRAM) {
                                mySVNEnvironment.getErr().println(svne.getErrorMessage().getMessage() != null ?
                                        svne.getErrorMessage().getMessage() : "Error running editor.");
                            } else {
                                throw svne;
                            }
                        }
                    } else {
                        mySVNEnvironment.getErr().println("Invalid option; there's no merged version to edit.");
                        mySVNEnvironment.getErr().println();
                    }
                } else if (answerChar == 'l') {
                    if (files.getBaseFile() != null && files.getLocalFile() != null &&
                            files.getRepositoryFile() != null && files.getResultFile() != null) {
                        try {
                            SVNCommandUtil.mergeFileExternally(mySVNEnvironment, files.getBasePath(),
                                    files.getRepositoryPath(), files.getLocalPath(), files.getResultPath());
                            performedEdit = true;
                        } catch (SVNException svne) {
                            if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.CL_NO_EXTERNAL_MERGE_TOOL) {
                                mySVNEnvironment.getErr().println(svne.getErrorMessage().getMessage() != null ?
                                        svne.getErrorMessage().getMessage() : "No merge tool found.");
                                myIsExternalFailed = true;
                            } else if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.EXTERNAL_PROGRAM) {
                                mySVNEnvironment.getErr().println(svne.getErrorMessage().getMessage() != null ?
                                        svne.getErrorMessage().getMessage() : "Error running merge tool.");
                                myIsExternalFailed = true;
                            } else {
                                throw svne;
                            }
                        }
                    } else {
                        mySVNEnvironment.getErr().println("Invalid option.");
                        mySVNEnvironment.getErr().println();
                    }
                } else if (answerChar == 'r') {
                    if (performedEdit) {
                        choice = SVNConflictChoice.MERGED;
                        break;
                    }
                    mySVNEnvironment.getErr().println("Invalid option.");
                    mySVNEnvironment.getErr().println();
                }
            }
        } else if (conflictDescription.getConflictAction() == SVNConflictAction.ADD &&
                conflictDescription.getConflictReason() == SVNConflictReason.OBSTRUCTED) {
            String message = "Conflict discovered when trying to add ''{0}''.";
            message = MessageFormat.format(message, new Object[] { files.getWCFile() });
            mySVNEnvironment.getErr().println(message);
            mySVNEnvironment.getErr().println("An object of the same name already exists.");
           
            String prompt = "Select: (p)ostpone, (M)ine-full, (T)heirs-full, (h)elp :";
            while (true) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.