1
votes

I'm currently adding support for feature branches in the Plastic SCM VCS Plugin. I think I have everything ready (clearly I'm wrong) but TeamCity detects all new changesets to belong to all branches. This renders the plugin unusable, since a new commit in the default branch would trigger a build in all active branches.

I have a PlasticVcsSupport class extending ServerVcsSupport. This is the PlasticVcsSupport.getCollectChangesPolicy() method:

@NotNull
public CollectChangesPolicy getCollectChangesPolicy() {
    return new PlasticCollectChangesPolicy(this, currentSettings, settingsLock);
}

This is an overview of the PlasticCollectChangesPolicy class: public class PlasticCollectChangesPolicy implements CollectChangesBetweenRepositories {

    @NotNull
    public RepositoryStateData getCurrentState(VcsRoot root) throws VcsException {
        /* ... */
        BranchInfo[] branches = QueryCommands.GetBranches(wi);

        return RepositoryStateData.createVersionState(
                mSettings.getSelectorBranch(), getBranchHeads(branches));
        /* ... */
    }

    @NotNull
    public List<ModificationData> collectChanges(
            @NotNull VcsRoot fromRoot,
            @NotNull RepositoryStateData fromState,
            @NotNull VcsRoot toRoot,
            @NotNull RepositoryStateData toState,
            @NotNull CheckoutRules checkoutRules) throws VcsException {
        return collectChanges(fromRoot, fromState, toState, checkoutRules);
    }

    public List<ModificationData> collectChanges(
            @NotNull VcsRoot vcsRoot,
            @NotNull RepositoryStateData fromState,
            @NotNull RepositoryStateData toState,
            @NotNull CheckoutRules checkoutRules) throws VcsException {
        /* ... */

        for (String branch : fromState.getBranchRevisions().keySet()){
            result.addAll(getDifferencesBetweenVersions(
                    vcsRoot,
                    wkInfo,
                    branch,
                    fromState.getBranchRevisions().get(branch),
                    toState.getBranchRevisions().get(branch)));
        }
        /* ... */

        return result;
    }
}

The getCurrentStatus() method seems to be working fine since new changes are being properly detected and the from/to states passed to the collectChanges() methods make sense. However, it seems I'm missing something to be set to the returned ModificationData objects, since TeamCity is unable to find out the branch for each ModificationData. I'm setting the proper parent changeset using the addParentRevision(String) method, but that achieved nothing. I've checked the git plugin code too, but I can't see what I'm missing :-(

This is how ModificationData are built:

List<VcsChange> files = /* fill changeset data */;
ModificationData md = new ModificationData(
    changeset.getDate(),
    files,
    changeset.getComments(),
    changeset.getOwner(),
    vcsRoot, // Unmodified
    changeset.getSpec(),
    changeset.getId());
md.addParentRevision(changeset.getParentSpec());

Any kind of help will be really appreciated :-)

Thanks!

1

1 Answers

1
votes

Make sure you include override:

public boolean isDAGBasedVcs() {return true;}