public class MergeReferenceGraph extends RootModuleVersionJobAbstractImpl
The principle of operation of this class is to traverse reference graphs in the
standard way using a List of root ModuleVersion's and a
ReferencePathMatcher to identify destination ModuleVersion's into which
a merge operation must be performed.
Generally the ReferencePathMatcher will be such that all ModuleVersion's in the reference graph under a root ModuleVersion are to be merged but the generic use of a ReferencePathMatcher allows to be selective about exactly which ModuleVersion's and reference graph subsets are to be merged. Furthermore, once a merge is performed into a destination ModuleVersion, traversal into this ModuleVersion is not performed, regardless of the ModuleVersion's matched by the ReferencePathMatcher.
There are actually two types of merge operations supported by Dragom. This
class implements the most common one. The other one is implemented by
MergeMain.
The type of merge performed by this class is used, for example, when:
Version
or the release static Version of a Module, into a dynamic Version
used for an ongoing development effort;
Model.
For each destination ModuleVersion visited during the traversal, a corresponding source ModuleVersion is selected. This source ModuleVersion is the one in the parallel reference graph rooted at the same Module corresponding to the initial matched destination ModuleVersion, but a dynamic Version initially specified externally (by the user). It is as if for each ReferencePath in the destination reference graph, the corresponding ModuleVersion is accessed in the source reference graph not considering the Version's within the source ReferencePath.
The destination Version will always be dynamic since the initial source Version specified by the user must be dynamic and the merge process is such that the other Version's encountered during the traversal are switched to dynamic if required before recursively invoking the merge process.
The destination ModuleVersion must be in a user workspace directory so that if merge conflicts are encountered, the user has a workspace where they can be resolved. If a destination ModuleVersion is not in a user workspace directory, it is checked out for the user.
In all cases below where merge or diverging commits are mentioned, commits that simply change the ArtifactVersion of the Module or the Version of its references are not considered. These commits are recognized with the commit attributes "dragom-version-change" and "dragom-reference-version-change".
We start by performing a merge using ScmPlugin.merge(java.nio.file.Path, org.azyva.dragom.model.Version, java.lang.String). We then iterate
through the child references in the destination ModuleVersion. For each child
reference that is a Module known to the Model and exists in the source
ModuleVersion without considering the Version, we perform the following
algorithm. Note that a corresponding reference in the source ModuleVersion
may not exist and there is nothing we can do. The presence or absence of a
corresponding reference is handled by the merge process itself at the SCM level.
If source and destination reference graphs do not have diverging commits, no merge is required. This case is not likely since we are generally talking about different Version's and given different Version's, we expect to have different source code.
If only the source reference graph diverges, the Version of the reference in the destination reference graph is changed to that of the source. This is possible since the parent is necessarily a dynamic Version.
If only the destination reference graph diverges, no merge is required since the destination contains all changes of the source.
If both the source and destination reference graphs diverge we have a merge conflict at the reference graph level. We inform the user and abort the merge process.
If source and destination reference graphs do not have diverging commits, no merge is required. This case is not likely, but possible if the source dynamic Version has just been created.
If the source reference graph diverges, use SwitchToDynamicVersion to
switch the static Version of the reference in the destination to a dynamic
Version, potentially creating a new dynamic Version, and continue with the case
below (both source and destination reference Version's dynamic). If the
destination reference graph also diverges issue a warning that the user should
expect the switched-to dynamic Version to also include these diverging commits.
If only the destination reference graph diverges, no merge is required.
RootModuleVersionJobAbstractImpl.UnsyncChangesBehaviorindAvoidReentry, indDepthFirst, indHandleDynamicVersion, indHandleStaticVersion, indListModuleVersionRootChanged, listActionsPerformed, listModuleVersionRoot, moduleReentryAvoider, MSG_PATTERN_KEY_ACTIONS_PERFORMED, MSG_PATTERN_KEY_CANNOT_PROCEED_WITH_UNSYNC_LOCAL_CHANGES, MSG_PATTERN_KEY_CONFLICTS_WHILE_UPDATING, MSG_PATTERN_KEY_DO_YOU_WANT_TO_UPDATE_UNSYNC_REMOTE_CHANGES, MSG_PATTERN_KEY_INITIATING_TRAVERSAL_REFERENCE_GRAPH_ROOT_MODULE_VERSION, MSG_PATTERN_KEY_MODULE_VERSION_ALREADY_PROCESSED, MSG_PATTERN_KEY_MULTIPLE_WORKSPACE_DIRECTORIES_FOR_MODULE, MSG_PATTERN_KEY_NO_ACTIONS_PERFORMED, MSG_PATTERN_KEY_ROOT_MODULE_VERSION_NOT_KNOWN, MSG_PATTERN_KEY_TRAVERSAL_REFERENCE_GRAPH_ROOT_MODULE_VERSION_COMPLETED, MSG_PATTERN_KEY_UPDATE_CHANGED_ROOT_MODULE_VERSION, MSG_PATTERN_KEY_UPDATE_ROOT_MODULE_VERSION_TO_DEFAULT, MSG_PATTERN_KEY_UPDATE_ROOT_MODULE_VERSION_TO_WORKSPACE_DIRECTORY_VERSION, MSG_PATTERN_KEY_UPDATING, MSG_PATTERN_KEY_VERSION_DOES_NOT_EXIST, MSG_PATTERN_KEY_VISITING_LEAF_MODULE_VERSION, MSG_PATTERN_KEY_VISITING_LEAF_REFERENCE_MATCHED, referencePath, RUNTIME_PROPERTY_PROJECT_CODE, RUNTIME_PROPERTY_SYNC_WORKSPACE_DIR, unsyncChangesBehaviorLocal, unsyncChangesBehaviorRemote| Constructor and Description |
|---|
MergeReferenceGraph(List<org.azyva.dragom.model.ModuleVersion> listModuleVersionRoot)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
visitMatchedModuleVersion(org.azyva.dragom.reference.Reference reference)
Visits a
ModuleVersion in the context of traversing the
ReferencePath for performing a merge. |
afterIterateListModuleVersionRoot, beforeIterateListModuleVersionRoot, beforeValidateListModuleVersionRoot, getProjectCode, getReferencePathMatcher, isListModuleVersionRootChanged, iterateListModuleVersionRoot, performJob, setIndAvoidReentry, setIndDepthFirst, setIndHandleDynamicVersion, setIndHandleStaticVersion, setIndListModuleVersionRootChanged, setReferencePathMatcherProvided, setUnsyncChangesBehaviorLocal, setUnsyncChangesBehaviorRemote, setupReferencePathMatcherForProjectCode, validateListModuleVersionRoot, visitModuleVersionpublic MergeReferenceGraph(List<org.azyva.dragom.model.ModuleVersion> listModuleVersionRoot)
listModuleVersionRoot - List of root ModuleVersion's within which new
static Version's must be created.protected boolean visitMatchedModuleVersion(org.azyva.dragom.reference.Reference reference)
ModuleVersion in the context of traversing the
ReferencePath for performing a merge. The Version of the module must be
dynamic.
This method has similarities with
RootModuleVersionJobAbstractImpl.visitModuleVersion(org.azyva.dragom.reference.Reference, org.azyva.dragom.apiutil.ByReference<org.azyva.dragom.model.Version>) in that they both
traverse a reference graph in some way. But they serve very different purposes.
visitModuleVersion is used to traverse the reference graph to find ModuleVersion's for which a merge has to be performed. This method takes over during that traversal when we know a merge has to be performed for the ModuleVersion.
This method does not perform the actual merge since for each matched
ModuleVersion it needs to perform setup operations once, after which it
delegates to mergeModuleVersion(org.azyva.dragom.reference.ReferencePath, org.azyva.dragom.reference.Reference).
visitMatchedModuleVersion in class RootModuleVersionJobAbstractImplreference - Reference to the matched ModuleVersion for which a merge
has to be performed.Copyright © 2015–2016 AZYVA INC.. All rights reserved.