Class AbstractMergePerformer
- java.lang.Object
-
- com._1c.g5.v8.dt.compare.git.merge.AbstractMergePerformer
-
- Direct Known Subclasses:
AbstractCherryPickPerformer
,AbstractMergeBranchPerformer
public abstract class AbstractMergePerformer extends Object
An abstract class that provides ability to perform Git merge using the EDT comparison and merge mechanism.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractMergePerformer.MergeFinishStatus
The merge process finish status.
-
Field Summary
Fields Modifier and Type Field Description protected IBmModelManager
bmModelManager
the Bm model managerprotected IComparisonManager
comparisonManager
the comparison managerprotected org.eclipse.jgit.api.MergeCommand.FastForwardMode
fastForwardMode
the fast forward mode.protected IQualifiedNameFilePathConverter
filePathConverter
the qualified name file path converterprotected MatchingStrategy
matchingStrategy
the matching strategyprotected boolean
parseBslModuleStructure
tells whether to compare a Bsl module with parsing module structureprotected String
refNameToMergeWith
the ref name to merge withprotected org.eclipse.jgit.lib.Repository
repository
the Git repositoryprotected IV8ProjectManager
v8ProjectManager
the V8 project manager
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMergePerformer(org.eclipse.jgit.lib.Repository repository, String refNameToMergeWith, MatchingStrategy matchingStrategy, boolean parseBslModuleStructure, org.eclipse.jgit.api.MergeCommand.FastForwardMode fastForwardMode, IQualifiedNameFilePathConverter filePathConverter, IBmModelManager bmModelManager, IV8ProjectManager v8ProjectManager, IComparisonManager comparisonManager, String mergeSettingsFileName)
Creates a new instance with the given parameters.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
doCommit(org.eclipse.jgit.lib.Ref headRef, org.eclipse.jgit.lib.Ref refToMergeWith, org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith)
Makes commit, writes the commit message and calls commit operation if necessary.protected abstract org.eclipse.jgit.revwalk.RevCommit
getBaseCommit(org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith, org.eclipse.jgit.revwalk.RevWalk revWalk)
Returns a base commit for the head commit and commit to merge with.protected abstract List<FileDiff>
getProjectDiffs(org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith, org.eclipse.jgit.revwalk.RevCommit baseCommit, String projectPath, org.eclipse.core.runtime.IProgressMonitor monitor)
Returns the project diffs for the specified commits.protected abstract void
onAdditionalFilesMergeFailed(org.eclipse.jgit.lib.Ref headRef, org.eclipse.jgit.lib.Ref refToMergeWith, org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith, org.eclipse.jgit.revwalk.RevCommit baseCommit, Map<String,org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason> failingPaths, List<String> unmergedPaths)
The callback method if the merge of the additional user files failed.protected abstract void
onComparisonFinished(CompareMergeProcessBatch batch, IMergeCallback callback, boolean hasPotentialProblems)
Called if the comparison finished.protected abstract void
onFastForwardDetected(org.eclipse.jgit.lib.Ref headRef, org.eclipse.jgit.lib.Ref refToMergeWith, org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith, org.eclipse.jgit.revwalk.RevWalk revWalk)
The callback method if fast-forward was detected.protected abstract void
onFastForwardFailed(org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith)
The callback method if fast-forward was expected (fast forward mode isMergeCommand.FastForwardMode.FF_ONLY
), but it was failed.protected abstract void
onMergeFinished(CompareMergeProcessBatch batch, IMergeCallback callback, AbstractMergePerformer.MergeFinishStatus status, org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith)
The callback to notify about finish of the merge process.protected abstract void
onMergeProblemsFound(List<CompareMergeProcessDescriptor> descriptors, List<ComparisonProcessHandle> handles, IMergeCallback callback)
The callback method if the merge problems were found.protected abstract void
onMergeUsingExternalToolFinished(CompareMergeProcessBatch batch)
The callback to notify about finish of the merge using an external tool process.protected abstract void
onNothingToMerge(org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith)
The callback method if there no changes to merge.void
perform(org.eclipse.core.runtime.IProgressMonitor monitor)
Performs the 3-way merge with the specified revision.protected void
runMerge(CompareMergeProcessBatch batch)
Runs the merge on the specified batch.protected void
startMergeAndWait(CompareMergeProcessBatch batch, org.eclipse.core.runtime.IProgressMonitor monitor)
Starts the merge and waits its finish.
-
-
-
Field Detail
-
repository
protected final org.eclipse.jgit.lib.Repository repository
the Git repository
-
refNameToMergeWith
protected final String refNameToMergeWith
the ref name to merge with
-
matchingStrategy
protected final MatchingStrategy matchingStrategy
the matching strategy
-
parseBslModuleStructure
protected final boolean parseBslModuleStructure
tells whether to compare a Bsl module with parsing module structure
-
fastForwardMode
protected final org.eclipse.jgit.api.MergeCommand.FastForwardMode fastForwardMode
the fast forward mode.
-
filePathConverter
protected final IQualifiedNameFilePathConverter filePathConverter
the qualified name file path converter
-
bmModelManager
protected final IBmModelManager bmModelManager
the Bm model manager
-
v8ProjectManager
protected final IV8ProjectManager v8ProjectManager
the V8 project manager
-
comparisonManager
protected final IComparisonManager comparisonManager
the comparison manager
-
-
Constructor Detail
-
AbstractMergePerformer
protected AbstractMergePerformer(org.eclipse.jgit.lib.Repository repository, String refNameToMergeWith, MatchingStrategy matchingStrategy, boolean parseBslModuleStructure, org.eclipse.jgit.api.MergeCommand.FastForwardMode fastForwardMode, IQualifiedNameFilePathConverter filePathConverter, IBmModelManager bmModelManager, IV8ProjectManager v8ProjectManager, IComparisonManager comparisonManager, String mergeSettingsFileName)
Creates a new instance with the given parameters.- Parameters:
repository
- the Git repository to run merge on, cannot benull
refNameToMergeWith
- the ref name to merge with, cannot benull
matchingStrategy
- the matching strategy, cannot benull
parseBslModuleStructure
- tells whether to compare and merge a Bsl module with parsing module structurefastForwardMode
- the fast forward mode, cannot benull
filePathConverter
- the qualified name file path converter, cannot benull
bmModelManager
- the Bm model manager, cannot benull
v8ProjectManager
- the V8 project manager, cannot benull
comparisonManager
- the comparison process manager, cannot benull
mergeSettingsFileName
- the merge settings file name, may benull
-
-
Method Detail
-
perform
public void perform(org.eclipse.core.runtime.IProgressMonitor monitor) throws IOException, org.eclipse.jgit.api.errors.GitAPIException, org.eclipse.core.runtime.CoreException, InvalidPreferencesFormatException
Performs the 3-way merge with the specified revision.- Parameters:
monitor
- the progress monitor to indicate progress, may benull
- Throws:
IOException
- if failed to read the Git repositoryorg.eclipse.jgit.api.errors.GitAPIException
- if failed to get the base commitorg.eclipse.core.runtime.CoreException
- if failed to open projects contained in the Git repositoryInvalidPreferencesFormatException
- if the input settings did not conform to the appropriate XML document type for a collection of preferences
-
getBaseCommit
protected abstract org.eclipse.jgit.revwalk.RevCommit getBaseCommit(org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith, org.eclipse.jgit.revwalk.RevWalk revWalk) throws org.eclipse.jgit.api.errors.GitAPIException, IOException
Returns a base commit for the head commit and commit to merge with.- Parameters:
headCommit
- the head commit, cannot benull
commitToMergeWith
- the commit to merge with, cannot benull
revWalk
- theRevWalk
instance, cannot benull
- Returns:
- the base commit or
null
if there is no base commit - Throws:
org.eclipse.jgit.api.errors.GitAPIException
- if failed to get the base commitIOException
- if failed to read the Git repository
-
getProjectDiffs
protected abstract List<FileDiff> getProjectDiffs(org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith, org.eclipse.jgit.revwalk.RevCommit baseCommit, String projectPath, org.eclipse.core.runtime.IProgressMonitor monitor) throws IOException
Returns the project diffs for the specified commits.- Parameters:
headCommit
- the head commit, cannot benull
commitToMergeWith
- the commit to merge with, cannot benull
baseCommit
- the base commit, cannot benull
projectPath
- the project path relative to repository root, cannot benull
monitor
- the monitor to indicate the progress, cannot benull
- Returns:
- the diff entries, never
null
- Throws:
IOException
- if it failed to read the Git repository
-
onNothingToMerge
protected abstract void onNothingToMerge(org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith)
The callback method if there no changes to merge.- Parameters:
headCommit
- the head commit, cannot benull
commitToMergeWith
- the commit to merge with, cannot benull
-
doCommit
protected abstract void doCommit(org.eclipse.jgit.lib.Ref headRef, org.eclipse.jgit.lib.Ref refToMergeWith, org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith)
Makes commit, writes the commit message and calls commit operation if necessary.- Parameters:
headRef
- the head ref, cannot benull
refToMergeWith
- the ref to merge with, cannot benull
headCommit
- the head commit, cannot benull
commitToMergeWith
- the commit to merge with, cannot benull
-
onFastForwardDetected
protected abstract void onFastForwardDetected(org.eclipse.jgit.lib.Ref headRef, org.eclipse.jgit.lib.Ref refToMergeWith, org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith, org.eclipse.jgit.revwalk.RevWalk revWalk)
The callback method if fast-forward was detected.- Parameters:
headRef
- the head ref, cannot benull
refToMergeWith
- the ref to merge with, cannot benull
headCommit
- the head commit, cannot benull
commitToMergeWith
- the commit to merge with, cannot benull
revWalk
- theRevWalk
instance, cannot benull
-
onFastForwardFailed
protected abstract void onFastForwardFailed(org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith)
The callback method if fast-forward was expected (fast forward mode isMergeCommand.FastForwardMode.FF_ONLY
), but it was failed.- Parameters:
headCommit
- the head commit, cannot benull
commitToMergeWith
- the commit to merge with, cannot benull
-
onAdditionalFilesMergeFailed
protected abstract void onAdditionalFilesMergeFailed(org.eclipse.jgit.lib.Ref headRef, org.eclipse.jgit.lib.Ref refToMergeWith, org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith, org.eclipse.jgit.revwalk.RevCommit baseCommit, Map<String,org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason> failingPaths, List<String> unmergedPaths)
The callback method if the merge of the additional user files failed.- Parameters:
headRef
- the head ref, cannot benull
refToMergeWith
- the ref to merge with, cannot benull
headCommit
- the head commit, cannot benull
commitToMergeWith
- the commit to merge with, cannot benull
baseCommit
- the base commit, cannot benull
failingPaths
- the list of paths causing the merge of the additional user files to fail, may benull
unmergedPaths
- the paths with conflicts, cannot benull
-
onComparisonFinished
protected abstract void onComparisonFinished(CompareMergeProcessBatch batch, IMergeCallback callback, boolean hasPotentialProblems)
Called if the comparison finished. After the comparison finished the merge didn't start automatically, to run merge callrunMerge(CompareMergeProcessBatch)
method.- Parameters:
batch
- the comparison merge process batch, cannot benull
callback
- the merge process callback, cannot benull
hasPotentialProblems
- tells whether the comparison batch has potential problems
-
onMergeProblemsFound
protected abstract void onMergeProblemsFound(List<CompareMergeProcessDescriptor> descriptors, List<ComparisonProcessHandle> handles, IMergeCallback callback)
The callback method if the merge problems were found.- Parameters:
descriptors
- the compare/merge process descriptors, cannot benull
handles
- the comparison handles with merge problems, cannot benull
callback
- the merge process callback, cannot benull
-
onMergeUsingExternalToolFinished
protected abstract void onMergeUsingExternalToolFinished(CompareMergeProcessBatch batch)
The callback to notify about finish of the merge using an external tool process.- Parameters:
batch
- the batch of compare/merge processes, cannot benull
-
onMergeFinished
protected abstract void onMergeFinished(CompareMergeProcessBatch batch, IMergeCallback callback, AbstractMergePerformer.MergeFinishStatus status, org.eclipse.jgit.revwalk.RevCommit headCommit, org.eclipse.jgit.revwalk.RevCommit commitToMergeWith)
The callback to notify about finish of the merge process. Called at the very end of this performer activity.- Parameters:
batch
- the batch of compare/merge processes, cannot benull
callback
- the merge process callback, cannot benull
status
- merge process finish status, cannot benull
headCommit
- the head commit, cannot benull
commitToMergeWith
- the commit to merge with, cannot benull
-
runMerge
protected void runMerge(CompareMergeProcessBatch batch)
Runs the merge on the specified batch. By default it starts the merge and waits its finish.- Parameters:
batch
- the batch of compare/merge processes to be merged, cannot benull
-
startMergeAndWait
protected void startMergeAndWait(CompareMergeProcessBatch batch, org.eclipse.core.runtime.IProgressMonitor monitor) throws InterruptedException
Starts the merge and waits its finish.- Parameters:
batch
- the batch of compare/merge processes to be merged, cannot benull
monitor
- the progress monitor to indicate progress, may benull
- Throws:
InterruptedException
- if the operation was interrupted
-
-