How to get the change set ID in VcsRepositoryViewer's getWebRepositoryUrlForFileDiff?

I'm trying to implement VcsRepositoryViewer for Perforce Swarm. The only way Swarm can display diffs for a file revision is on the same page that shows the commit that the file revision was part of. Because of this, I need access to both the filename and change set ID in order to generate the appropriate link to view diffs. getWebRepositoryUrlForFileDiff() currently only has access to the filename and revision.

I can return null from getWebRepositoryUrlForFileDiff() to hide the "(diffs)" link for now, but it would be great if we could get the diff link working without supplying our own template to replace the built-in one.

Is there any way to get access to the change set ID in this function? I realize the design of this new plugin point was to be stateless, so I assume not, but we'd really like to get this working if possible. The problem seems to be that defaultCommitView.ftl has

[#local fileDiffUrl = linkGenerator.getWebRepositoryUrlForFileDiff(file, repositoryData)!/]
[#if fileDiffUrl?has_content]
    <a href="${fileDiffUrl}">(diffs)</a>
[/#if]


coded into it so unless we replace the template with our own, I don't see how to do this right now.

Any feedback would be appreciated!

1 answer

1 accepted

0 votes
  if (file.isRevisionKnown())
        {
            String revision = file.getRevision();
}

Thanks for contributing, but Perforce separates the concept of file revision from commit ID, so revision 2 of a file could be in commit 1000. In that example, the 1000 (commit.getChangeSetId()) is the part I'd need while I currently only have the 2.

If this is not something that's currently possible, where can I enter a feature request to get it added?

> revision 2 of a file could be in commit 1000.

Please help me understand, are you saying that file changed in commit 1000 can have revision number 2?

As you can imagine, usually it's not the case. Do you use Bamboo's built-in Perforce plugin to generate the changelists or something else?

Update: you probably don't, because in our Perforce plugin we deliberately ignore file revisions when creating CommitFile objects and set file revision to commit revision. If you are developer of Perforce Swarp repository plugin, then perhaps the easiest thing is to do the same.

I opened this improvement request to fix our API: https://jira.atlassian.com/browse/BAM-18354

> Please help me understand, are you saying that file changed in commit 1000 can have revision number 2?

Yes, that's exactly correct.

> Do you use Bamboo's built-in Perforce plugin to generate the changelists or something else?

We have written our own Perforce plugin to fully support Perforce Streams using the new VCS plugin points in Bamboo 5.14. I hope to be able to release it once we've completed work on it.

> If you are developer of Perforce Swarp repository plugin, then perhaps the easiest thing is to do the same.

It's important to us to be able to separate file revision from commit ID because the two are distinct and each has its use in Perforce. I also use Git so I understand that other VCS's handle things differently. :)

> I opened this improvement request to fix our API: https://jira.atlassian.com/browse/BAM-18354

Thank you!

Suggest an answer

Log in or Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,066 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot