using System; using System.Text; using p4dn; using System.IO; namespace P4API { /// /// Actions to take when resolving a file. /// /// /// ///
  • CMS_QUIT user wants to quit
  • ///
  • CMS_SKIP skip the integration record
  • ///
  • CMS_MERGED accepted merged theirs and yours
  • ///
  • CMS_EDIT accepted edited merge
  • ///
  • CMS_THEIRS accepted theirs
  • ///
  • CMS_YOUR accepted yours
  • ///
    ///
    public enum MergeAction { /// /// Quit the resolve workflow. /// Quit, // CMS_QUIT user wants to quit /// /// Skip this file in the resolve workflow. /// Skip, // CMS_SKIP skip the integration record /// /// Accept the merged file from Perforce. This file must not be edited. /// AcceptMerged, // CMS_MERGED accepted merged theirs and yours /// /// Accept the result file with your edits. The result file should be edited before returning this merge action. /// AcceptEdit, // CMS_EDIT accepted edited merge /// /// Accept 'their' file ('your' changes will be lost). /// AcceptTheirs, // CMS_THEIRS accepted theirs /// /// Accept 'your' file ('thier' changes will be lost). /// AcceptYours // CMS_YOUR accepted yours } /// /// Contains information about the files being merged. /// public class MergeData { private P4MergeData _mergeData; internal MergeData(P4MergeData mergeData) { _mergeData = mergeData; } /// /// Base file for the 3-way merge. /// public FileInfo BaseFile { get { return _mergeData.GetBasePath(); } } /// /// Your file for the 3-way merge. /// public FileInfo YourFile { get { return _mergeData.GetYourPath(); } } /// /// Perforce's recommended merge action. /// public MergeAction MergeHint { get { switch (_mergeData.GetMergeHint()) { case P4MergeStatus.CMS_QUIT: return MergeAction.Quit; case P4MergeStatus.CMS_SKIP: return MergeAction.Skip; case P4MergeStatus.CMS_EDIT: return MergeAction.AcceptEdit; case P4MergeStatus.CMS_MERGED: return MergeAction.AcceptMerged; case P4MergeStatus.CMS_YOURS: return MergeAction.AcceptYours; case P4MergeStatus.CMS_THEIRS: return MergeAction.AcceptTheirs; } return MergeAction.Quit; } } /// /// Thier file for the 3-way merge. /// public FileInfo TheirFile { get { return _mergeData.GetTheirPath(); } } /// /// File where merged result should be written. /// public FileInfo ResultFile { get { return _mergeData.GetResultPath(); } } /// /// Perforce name of the base file. Format is '//depot/path/file.ext#rev'. /// public string BaseName { get { return _mergeData.GetBaseName(); } } /// /// Perforce name of your file. Format is '//client/path/file.ext'. /// public string YourName { get { return _mergeData.GetYourName(); } } /// /// Perforce name of thier file. Format is '//depot/path/file.ext#rev'. /// public string TheirName { get { return _mergeData.GetTheirName(); } } /// /// Runs the external merge tool configured by P4MERGE. /// /// True if the merge tool exits with code 0, false otherwise. public bool RunMergeTool() { return _mergeData.RunMergeTool(); } } }