How FishEye server deal with ChangeSets?Sorting revision algorithm is unkonwn!!!!

Q W April 3, 2012

Hello guys!

I am trying to develop a simple plugin for FishEye server which would handle with some svn-like client.

The hardest thing is implement an iterative review functionality.

The main idea of ‘iterative review’ is when we add file with some revision2 to existing review and that file is already exist in this review with revision1 we should gather all information about revisions. I implement com.atlassian.crucible.scm.ChangelogBrowser interface and in method listChanges realized simpe algorithm:call method com.atlassian.crucible.spi.services.ReviewService.getReviewDetails, retriew all revisions of curent flie in existing review, and add them to changset.

Result -- revisions are not sorted by FishEye server as good as I want.For example, when I send versions 1,2,3. to FishEye it display 2,3,1. And next verstions are added between last and first: 2,3,4,5,6,.....,1.


Could you please help me to understand where is the problem?

Could you please share with me information how FishEye server deal with ChangeSets?

Simple code example:

public ChangeSets listChanges(Principal principal, String path,
String oldestCsid, boolean includeOldest, String newestCsid,
boolean includeNewest, int maxChangesets) {
if (newestCsid == null || newestCsid.isEmpty()) {
return new ChangelogBrowser.ChangeSets(false, false, new ArrayList<ChangeSet>());
}
.............................
// fill List with data
String curRevision = getRevision(newestCsid); String cuPath = getPath(newestCsid);

List<RevisionKey> revisionList = new ArrayList<RevisionKey>();
revisionList.add(new RevisionKey(curPath, curRevision));
revisionList.addAll(getAllRevisionByFile(curRevision));
ArrayList<ChangeSet> changeSet = new ArrayList<ChangeSet>();
.............................
changeSet.add(new ChangeSet(newestCsid, revisionList));
return new ChangelogBrowser.ChangeSets(false, false, changeSet);
}

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Q W June 11, 2012

Hello, Geoff,

Thank you a lot for response.

I am using Rest API for creating and adding filed to review.

I make POST request to rest-service/reviews-v1 to create review and POST request to rest-service/reviews-v1/<CR-X>/addChangeset to add files.

I set create date to first revision when I create review. It works same as without date.

Also I noticed that there is some logical connection between methods listChanges from com.atlassian.crucible.scm.ChangelogBrowser and getDiffRevisionKey from com.atlassian.crucible.scm.SCMRepository.

If I impement getDiffRevisionKey in bellow way Crucible will sort revision in reverse order(5 4 3 2 1)

public RevisionKey getDiffRevisionKey(Principal aPrinc, RevisionKey aRevKey) throws NotFoundException {		
            return aRevKey;    	

}



0 votes
Geoff Crain
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 11, 2012

Hi,

Crucible only supports date-based iterative reviews for plugin SCMs. That is, what is supposed to happen: if revisions 1, 2 and 3, and they have increasing commit dates, then adding them to the review in any order will produce an "iterative file" in the review with the revisions in order: 1, 2, 3.

Since yours are ending up as eg. 2, 3, 4, 5, 1, it seems like the algorithm is calculating it "almost right". This may be due to one of a few things. One is that our calculation is wrong - i will post the method that does this below, but I tested this with our SVN plugin, and it works.

Another possibility is that Crucible doesnt know the date for the first revision that you are adding. The almost correct insertion of the other revisions makes me think that it is only the first revision that is missing the date.

There are various ways to create reviews in Crucible - from what I understand, you are using REST APIs? Have you tried creating the same review from the Crucible UI to see if it creates the same behaviour?

Can you please let us know what rest end point you are using to add the initial revision to the review, and what you are using to add additional iterations?

Geoff

insert position calculation based existing file revisions: ("knownMax" is used when adding 2 revisions at once in the case that dates are out of order)

public int getInsertIndex(List&lt;CrucibleRevision&gt; existingRevisions, CrucibleRevision fr, CrucibleRevision knownMax) throws SourceException {
        validateRevisionSource(fr);
        if (!existingRevisions.contains(fr)) {
            boolean needsAdd = true;

            int i = 0;
            for (CrucibleRevision currentRev : existingRevisions) {
                validateRevisionSource(currentRev);
                if ((fr.getCommitDate() != null &amp;&amp; currentRev.getCommitDate() != null &amp;&amp; fr.getCommitDate().before(currentRev.getCommitDate()))
                        || currentRev.equals(knownMax)) {
                    break;
                } else if (fr.getRevInfoKey().equals(currentRev.getRevInfoKey())) {
                    needsAdd = false;
                    break;
                }
                i++;
            }
            if (needsAdd) {
                return i;
            }
        }
        return -1;
    }

Q W June 11, 2012

Hello, Geoff,

Thank you a lot for response.

I am using Rest API for creating and adding filed to review.

I make POST request to rest-service/reviews-v1 to create review and POST request to rest-service/reviews-v1/<CR-X>/addChangeset to add files.

I set create date to first revision when I create review. It works same as without date.

Also I noticed that there is some logical connection between methods listChanges from com.atlassian.crucible.scm.ChangelogBrowser and getDiffRevisionKey from com.atlassian.crucible.scm.SCMRepository.

If I impement getDiffRevisionKey in bellow way Crucible will sort revision in reverse order(5 4 3 2 1)

public RevisionKey getDiffRevisionKey(Principal aPrinc, RevisionKey aRevKey) throws NotFoundException {		
            return aRevKey;    	

}
Geoff Crain
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 12, 2012

Hi,

Im not sure what you mean by "I set create date to first revision when I create review. It works same as without date.", so I want to establish that we're talking about the same thing.

The date has to be set in a details map on the ChangeSet object returned by listChanges. Here is an example of how the svn plugin does it:

https://bitbucket.org/atlassian/crucible-svn-scm-plugin/src/899af8d0c753/src/main/java/com/atlassian/crucible/plugins/scm/svn/SvnChangelogBrowser.java#cl-164

It does seem odd that changing getDiffRevisionKey would produce that behaviour. I changed the svn implementation and saw something different: it just considered each revision to be an "addition" rather than a "modification".

Does it behave differently based on the order that you add the revisions?

It would help if you could share the source of your plugin - you can upload a zip to your support ticket.

Alternatively, Im not sure if you knew about these, but we have some fairly complete examples of integration for svn, perforce and git that you can compare with:

https://bitbucket.org/atlassian/crucible-svn-scm-plugin

https://bitbucket.org/atlassian/crucible-p4-scm-plugin

https://bitbucket.org/atlassian/crucible-git-scm-plugin

Geoff

Q W June 12, 2012

Hello,

As far as I know, we can pass detail information to Crucible via REST. So I use http://docs.atlassian.com/fisheye-crucible/latest/javadoc/com/atlassian/crucible/spi/data/ReviewData.html for sending information about date.

Also I try to set date in listChanges inside plugin as you propose. No result in both cases.

Revision passed to Crucible should be sorted according to http://docs.atlassian.com/fisheye-crucible/latest/javadoc/com/atlassian/crucible/scm/ChangelogBrowser.html

When I tried to sort revision in any other way, they was shown in really strange order.

Maybe you know how crucible deal with revision? I noticed some connection between method listChanges and getDiffRevisionKey. Unfortunetely, I cant see any logical sence. If we return list of revision why Crucible trying to calculate previous for each revision? Looks like Crucible gather list of revision to show from 2 sourse - method listChangeset and getDiffRevisionKey. After collecting all revision it try to sort them by method getInsertIndex.

Geoff Crain
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 14, 2012

Hi,

Ive opened a support ticket and uploaded a dev build with extra logging so we can hopefully see whats going on.

Geoff

TAGS
AUG Leaders

Atlassian Community Events