Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SONARSCPER-4 Do not fail when a file has no blame information #7

Merged
merged 5 commits into from
Jan 6, 2016

Conversation

henryju
Copy link
Contributor

@henryju henryju commented Dec 18, 2015

No description provided.

@mjdetullio
Copy link
Contributor

Properly skips unsubmitted files, allowing analysis to complete, but still got the Changeset must have a date error in the Compute Engine. I haven't tested it with a 5.3 RC that has the new logging yet though. Going to try that to get the file that is failing in CE.

The warning at the end of the analysis reported missing info for two files, one was my unsubmitted file and the other was submitted with only one revision. There is a Perforce bug (I won't go into detail) that results in the null date. The logs for it report Ignoring blame result since provider returned 63 blame lines but file [redacted] has 62 lines, which would be correct since the bug occurs on one line. I just feel as if this should not cause a CE failure.

@henryju
Copy link
Contributor Author

henryju commented Jan 4, 2016

@mjdetullio Thanks for testing. I'm a bit surprised of the failure on CE side since the message Ignoring blame result since provider returned 63 blame lines but file [redacted] has 62 lines should mean the file is completely skipped (and so should not be processed by compute engine. Are you testing from scratch (ie from a new project) or do you have existing data for the same project in SQ server?

@mjdetullio
Copy link
Contributor

SQ 5.2, new project.

On that note, an existing project in our production SQ 5.2 started failing with the Changeset must have a date error in CE after testing this PR when it was not failing before. I only noticed this just yesterday. After reverting back to current master branch, it was fine again.

Testing with a local SQ 5.3-RC2 instance, this PR, and as a new project, it now fails during analysis and not in CE. No apparent error message, even with sonar.verbose=true. Analysis seems to stop on the problem file without noting which one it is. Adding the -e argument to the runner (or --stacktrace to Gradle) reveals the same problem... Blame date is null for file [redacted] at line 22.

Note that this file shows no issues when running the p4 filelog and p4 annotate commands that are equivalent of those used in p4java, so it's not related to the other Perforce bug I mentioned. I can go to the changelist assigned for that line using P4V and there is indeed a "date submitted" there.

11:07:44.306 INFO  - Sensor SCM Sensor (wrapped)
11:07:44.310 INFO  - SCM provider for this project is: perforce
11:07:44.315 INFO  - 2445 files to be analyzed
11:07:44.316 DEBUG - Working directory: /Users/mjdetullio/redacted-project
11:07:44.815 DEBUG - info
11:07:45.108 DEBUG - Command completed in 711ms
11:07:45.119 DEBUG - login -s
11:07:45.547 DEBUG - Command completed in 434ms
11:07:45.549 DEBUG - User mjdetullio ticket expires in 11 hours 59 minutes.
11:07:45.550 DEBUG - User mjdetullio ticket expires in 11 hours 59 minutes.
11:07:45.557 DEBUG - client -o myp4client
11:07:46.150 DEBUG - Command completed in 600ms
11:07:46.184 DEBUG - where /Users/mjdetullio/redacted-project
11:07:46.594 DEBUG - Command completed in 417ms
11:07:46.605 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:47.052 DEBUG - Command completed in 453ms
11:07:47.096 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:47.719 DEBUG - Command completed in 665ms
11:07:47.735 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:48.382 DEBUG - Command completed in 653ms
11:07:48.390 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:48.898 DEBUG - Command completed in 516ms
11:07:49.028 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:49.546 DEBUG - Command completed in 647ms
11:07:49.553 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:50.021 DEBUG - Command completed in 474ms
11:07:50.028 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:50.568 DEBUG - Command completed in 546ms
11:07:50.575 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:50.971 DEBUG - Command completed in 402ms
11:07:50.978 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:51.384 DEBUG - Command completed in 412ms
11:07:51.391 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:51.821 DEBUG - Command completed in 437ms
11:07:51.829 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:52.234 DEBUG - Command completed in 411ms
11:07:52.240 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:52.654 DEBUG - Command completed in 420ms
11:07:52.662 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:53.082 DEBUG - Command completed in 426ms
11:07:53.088 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:53.485 DEBUG - Command completed in 403ms
11:07:53.492 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:53.910 DEBUG - Command completed in 424ms
11:07:53.918 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:54.278 DEBUG - Command completed in 367ms
11:07:54.286 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:07:54.315 INFO  - 8/2445 files analyzed
... omitted for brevity - nothing useful here ...
11:08:04.317 INFO  - 18/2445 files analyzed
... omitted for brevity - nothing useful here ...
11:08:14.318 INFO  - 29/2445 files analyzed
... omitted for brevity - nothing useful here ...
11:08:24.320 INFO  - 40/2445 files analyzed
... omitted for brevity - nothing useful here ...
11:08:34.320 INFO  - 51/2445 files analyzed
11:08:34.536 DEBUG - Command completed in 424ms
11:08:34.543 DEBUG - annotate -c -i -db /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:08:34.961 DEBUG - Command completed in 425ms
11:08:34.967 DEBUG - filelog -i /Users/mjdetullio/redacted-project/redacted-file.ext#have
11:08:35.366 DEBUG - Command completed in 405ms
11:08:35.368 INFO  - 52/2445 files analyzed
11:08:35.368 WARN  - Missing blame information for the following files:
11:08:35.368 WARN  -   * /Users/mjdetullio/redacted-project/redacted-file.ext
... list of remaining 2393 files in the index that were not blamed yet ...
11:08:35.433 WARN  -   * /Users/mjdetullio/redacted-project/redacted-file.ext
11:08:35.433 WARN  - This may lead to missing/broken features in SonarQube
11:08:35.435 INFO  - Analysis report generated in /Users/mjdetullio/redacted-project/build/sonar/batch-report
:sonarqube FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonarqube'.
> Unable to execute Sonar

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonarqube'.
        ... omitted for brevity ...
Caused by: org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        ... omitted for brevity ...
Caused by: java.lang.IllegalArgumentException: Blame date is null for file [redacted] at line 22
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:148)
    at org.sonar.batch.scm.DefaultBlameOutput.validateLine(DefaultBlameOutput.java:105)
    at org.sonar.batch.scm.DefaultBlameOutput.blameResult(DefaultBlameOutput.java:87)
    at org.sonar.plugins.scm.perforce.PerforceBlameCommand.computeBlame(PerforceBlameCommand.java:119)
    at org.sonar.plugins.scm.perforce.PerforceBlameCommand.blame(PerforceBlameCommand.java:96)
    at org.sonar.plugins.scm.perforce.PerforceBlameCommand.blame(PerforceBlameCommand.java:62)
    at org.sonar.batch.scm.ScmSensor.execute(ScmSensor.java:84)
        ... omitted for brevity ...


BUILD FAILED

@mjdetullio
Copy link
Contributor

This is giving me more trouble than I expected. There is no combination of p4 filelog arguments that will give ALL possible changelist numbers given by p4 annotate. Adding the -h option to filelog will show some CLs needed by one file and work fine, but then it hides CLs needed for others.

The only way it's possible to get authors/dates for all revisions is to build a list of revisions from the annotate command and then get info for each of those revisions. What a nightmare.

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

Hi all! @henryju sent me here in response to an issue I've been having with Perforce SCM since 5.2, which I've been discussing on the Google Group. I'm now running 5.3-RC2 and just pulled the perforce plugin snapshot (1.3-rc1).

This is what I'm getting now when running the analysis (client side):

[INFO] [08:40:02.628] Sensor SCM Sensor (wrapped)
[INFO] [08:40:02.628] SCM provider for this project is: perforce
[INFO] [08:40:02.628] 2 files to be analyzed
[DEBUG] [08:40:02.628] Working directory: D:\jenkins\jenkins-05\workspace\prodcore-trunk-funcTests-sonar\dev\services\coreservice\core
[DEBUG] [08:40:02.753] info
[DEBUG] [08:40:02.753] Command completed in 31ms
[DEBUG] [08:40:02.769] client -o prodcore-trunk-funcTests-sonar--1491847797
[DEBUG] [08:40:02.769] Command completed in 0ms
[DEBUG] [08:40:02.785] where D:\jenkins\jenkins-05\workspace\prodcore-trunk-funcTests-sonar\dev\services\coreservice\core
[DEBUG] [08:40:02.800] Command completed in 15ms
[DEBUG] [08:40:02.800] annotate -c -i -db D:/jenkins/jenkins-05/workspace/prodcore-trunk-funcTests-sonar/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#have
[DEBUG] [08:40:03.097] Command completed in 297ms
[DEBUG] [08:40:03.097] change -o 888936
[DEBUG] [08:40:03.113] Command completed in 16ms
[DEBUG] [08:40:03.113] change -o 878541
[DEBUG] [08:40:03.113] Command completed in 0ms
[DEBUG] [08:40:03.113] change -o 106336
[DEBUG] [08:40:03.160] Command completed in 47ms
[DEBUG] [08:40:03.160] change -o 106385
[DEBUG] [08:40:03.160] Command completed in 0ms
[ERROR] [08:40:03.160] Change 106385 unknown.
[INFO] [08:40:03.160] 0/2 files analyzed
[WARN] [08:40:03.160] Missing blame information for the following files:
[WARN] [08:40:03.160]   * D:/jenkins/jenkins-05/workspace/prodcore-trunk-funcTests-sonar/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java
[WARN] [08:40:03.160]   * D:/jenkins/jenkins-05/workspace/prodcore-trunk-funcTests-sonar/dev/services/coreservice/core/src/test/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverterTestCase.java
[WARN] [08:40:03.160] This may lead to missing/broken features in SonarQube

The error here is "Change 106385 unknown.". This changelist is from a different Perforce server (it was imported by branching from one linked server to another), so it can't be queried. The same goes for the prior one, 106336 -- this changelist happens to exist on both, but it's the WRONG CHANGELIST if you query it on this server! IT MUST NOT BE INCLUDED.

When you were previously using p4 filelog, these changelists would have shown as being checked in by remote@remote (user@workspace), which tells you that it can be ignored. However when you're using just p4 annotate there's no way to know that, so you've now lost some information.

Here's what the filelog looks like for this file the way that the 1.2 plugin runs it:

//our_product/trunk/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java
... #6 change 911479 edit on 2015/11/19 by jons@jons-prd-trunk (text+ko) 'Rally US803. Maps the legacy ty'
... #5 change 888936 edit on 2015/07/20 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Add IDEA copyright settings fil'
... ... branch into //our_product/Haifa/trunk/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#1
... ... branch into //our_product/branches/12.2/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#1
... ... branch into //users/davisa/prd/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#1
... #4 change 888919 edit on 2015/07/20 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Address a lot of major SonarQub'
... #3 change 888362 edit on 2015/07/14 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Replace all tab characters with'
... #2 change 880692 edit on 2015/05/26 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Add PMD static code analysis in'
... #1 change 878541 move/add on 2015/05/11 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Move to com.ourcompany and bett'
... ... moved from //our_product/trunk/dev/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
//our_product/trunk/dev/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java
... #1 change 878223 move/add on 2015/05/08 by tyrelha@tyrel3-everything (text+ko) 'Move files into dev '
... ... moved into //our_product/trunk/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#1
... ... moved from //our_product/trunk/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
//our_product/trunk/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java
... #1 change 878215 import on 2015/05/08 by tyrelha@tyrel3-everything (text+ko) 'Initial integration of code int'
... ... branch from //OurProduct_1666/Trunk/Dev/com/cmp/prd/server/resources/LegacyTypeConverter.java#1,#4
... ... moved into //our_product/trunk/dev/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
//OurProduct_1666/Trunk/Dev/com/cmp/prd/server/resources/LegacyTypeConverter.java
... #4 change 106385 edit on 2015/03/27 by remote@remote (text+ko)
... ... branch into //OurProduct/Trunk/Dev/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
... ... branch into //our_product/trunk/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
... #3 change 106360 edit on 2015/03/23 by remote@remote (text+ko)
... #2 change 106339 edit on 2015/03/17 by remote@remote (text+ko)
... #1 change 106336 add on 2015/03/16 by remote@remote (text+ko)

All of the changelists from remote@remote should be ignored.

@mjdetullio
Copy link
Contributor

So then what's the best solution? Like I said, p4 filelog doesn't always
produce a complete list of CLs.

Should p4 filelog still be used and then fall back to p4 change if the
change isn't found? What if it's still not found by p4 change?

Because of SQ 5.2+'s requirement of date and author for each line, we need
to settle on a way to populate data for these edge cases.
On Jan 5, 2016 11:55 AM, "Tyrel Haveman" notifications@github.com wrote:

Hi all! @henryju https://github.com/henryju sent me here in response to
an issue I've been having with Perforce SCM since 5.2, which I've been
discussing on the Google Group. I'm now running 5.3-RC2 and just pulled the
perforce plugin snapshot (1.3-rc1).

This is what I'm getting now when running the analysis (client side):

[INFO] [08:40:02.628] Sensor SCM Sensor (wrapped)
[INFO] [08:40:02.628] SCM provider for this project is: perforce
[INFO] [08:40:02.628] 2 files to be analyzed
[DEBUG] [08:40:02.628] Working directory: D:\jenkins\jenkins-05\workspace\prodcore-trunk-funcTests-sonar\dev\services\coreservice\core
[DEBUG] [08:40:02.753] info
[DEBUG] [08:40:02.753] Command completed in 31ms
[DEBUG] [08:40:02.769] client -o prodcore-trunk-funcTests-sonar--1491847797
[DEBUG] [08:40:02.769] Command completed in 0ms
[DEBUG] [08:40:02.785] where D:\jenkins\jenkins-05\workspace\prodcore-trunk-funcTests-sonar\dev\services\coreservice\core
[DEBUG] [08:40:02.800] Command completed in 15ms
[DEBUG] [08:40:02.800] annotate -c -i -db D:/jenkins/jenkins-05/workspace/prodcore-trunk-funcTests-sonar/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#have
[DEBUG] [08:40:03.097] Command completed in 297ms
[DEBUG] [08:40:03.097] change -o 888936
[DEBUG] [08:40:03.113] Command completed in 16ms
[DEBUG] [08:40:03.113] change -o 878541
[DEBUG] [08:40:03.113] Command completed in 0ms
[DEBUG] [08:40:03.113] change -o 106336
[DEBUG] [08:40:03.160] Command completed in 47ms
[DEBUG] [08:40:03.160] change -o 106385
[DEBUG] [08:40:03.160] Command completed in 0ms
[ERROR] [08:40:03.160] Change 106385 unknown.
[INFO] [08:40:03.160] 0/2 files analyzed
[WARN] [08:40:03.160] Missing blame information for the following files:
[WARN] [08:40:03.160] * D:/jenkins/jenkins-05/workspace/prodcore-trunk-funcTests-sonar/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java
[WARN] [08:40:03.160] * D:/jenkins/jenkins-05/workspace/prodcore-trunk-funcTests-sonar/dev/services/coreservice/core/src/test/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverterTestCase.java
[WARN] [08:40:03.160] This may lead to missing/broken features in SonarQube

The error here is "Change 106385 unknown.". This changelist is from a
different Perforce server (it was imported by branching from one linked
server to another), so it can't be queried. The same goes for the prior
one, 106336 -- this changelist happens to exist on both, but it's the WRONG
CHANGELIST if you query it on this server! IT MUST NOT BE INCLUDED.

When you were previously using p4 filelog, these changelists would have
shown as being checked in by remote@remote (user@workspace), which tells
you that it can be ignored. However when you're using just p4 annotate
there's no way to know that, so you've now lost some information.

Here's that the filelog looks like for this file the way that the 1.2
plugin runs it:

//our_product/trunk/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java
... #6 change 911479 edit on 2015/11/19 by jons@jons-prd-trunk (text+ko) 'Rally US803. Maps the legacy ty'
... #5 change 888936 edit on 2015/07/20 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Add IDEA copyright settings fil'
... ... branch into //our_product/Haifa/trunk/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#1
... ... branch into //our_product/branches/12.2/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#1
... ... branch into //users/davisa/prd/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#1
... #4 change 888919 edit on 2015/07/20 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Address a lot of major SonarQub'
... #3 change 888362 edit on 2015/07/14 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Replace all tab characters with'
... #2 change 880692 edit on 2015/05/26 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Add PMD static code analysis in'
... #1 change 878541 move/add on 2015/05/11 by tyrelha@tyrel3-prdcore-trunk (text+ko) 'Move to com.ourcompany and bett'
... ... moved from //our_product/trunk/dev/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
//our_product/trunk/dev/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java
... #1 change 878223 move/add on 2015/05/08 by tyrelha@tyrel3-everything (text+ko) 'Move files into dev '
... ... moved into //our_product/trunk/dev/services/coreservice/core/src/main/java/com/ourcompany/ourprod/core/resources/LegacyTypeConverter.java#1
... ... moved from //our_product/trunk/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
//our_product/trunk/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java
... #1 change 878215 import on 2015/05/08 by tyrelha@tyrel3-everything (text+ko) 'Initial integration of code int'
... ... branch from //OurProduct_1666/Trunk/Dev/com/cmp/prd/server/resources/LegacyTypeConverter.java#1,#4
... ... moved into //our_product/trunk/dev/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
//OurProduct_1666/Trunk/Dev/com/cmp/prd/server/resources/LegacyTypeConverter.java
... #4 change 106385 edit on 2015/03/27 by remote@remote (text+ko)
... ... branch into //OurProduct/Trunk/Dev/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
... ... branch into //our_product/trunk/services/coreservice/core/src/main/java/com/cmp/prd/server/resources/LegacyTypeConverter.java#1
... #3 change 106360 edit on 2015/03/23 by remote@remote (text+ko)
... #2 change 106339 edit on 2015/03/17 by remote@remote (text+ko)
... #1 change 106336 add on 2015/03/16 by remote@remote (text+ko)

All of the changelists from remote@remote should be ignored.


Reply to this email directly or view it on GitHub
#7 (comment)
.

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

In my opinion, SQ must not require a date and author for each line of code. Sometimes (like here, with imported source control data), that's simply not available.

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

Alternatively, instead of p4 change -o ####, you could try p4 filelog -c ####, which would just return the filelog for that changelist. Hopefully in the case if imported changelists it will show remote@remote which will be sufficient information.

@mjdetullio
Copy link
Contributor

Can you verify that functionality of p4 filelog -c with your imported
changelists? If it gives you your intended results I'll prototype it with
my projects.
On Jan 5, 2016 12:40 PM, "Tyrel Haveman" notifications@github.com wrote:

Alternatively, instead of p4 change -o ####, you could try p4 filelog -c
####, which would just return the filelog for that changelist. Hopefully in
the case if imported changelists it will show remote@remote which will be
sufficient information.


Reply to this email directly or view it on GitHub
#7 (comment)
.

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

Sorry, filelog -c doesn't do what I thought it would do.

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

I noticed that IntelliJ IDEA I can annotate the file I posted info about earlier, and it shows a username on every line, even though many of them are from imported revisions. It's displaying my own username; that could either because I was the one that imported it or because I'm the current user. I will investigate how it is doing this and get back to you.

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

Based on what I'm seeing in IDEA, it looks like it's using annotate -I rather than annotate -i. The changelist numbers its showing are consistent with that. Does that seem like an unreasonable thing to do here?

@mjdetullio
Copy link
Contributor

You can use -I instead of -i (you can only use one or the other) by changing options.setFollowBranches(true) to options.setFollowAllIntegrations(true). I tried this before and didn't notice much of a difference in results.

If you can rebuild from source with that change and report back results it would be useful.

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

Good news! I pulled the branch feature/ignore_unsubmitted_files, changed it to use options.setFollowAllIntegrations(true) as you suggested, and it works great. We're getting source control information in SonarQube for the first time in a few months!

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

By the way, the Perforce documentation says that -c is implied with either -i or -I, so you can remove the call to options.setUseChangeNumbers(true).

@mjdetullio
Copy link
Contributor

Alright, I can live with that. -I works fine for me as well. Opened additional PR. Hopefully that gives us a solid 1.3 release.

@tyrel
Copy link
Contributor

tyrel commented Jan 5, 2016

Outstanding! Thanks @mjdetullio

henryju and others added 5 commits January 6, 2016 15:32
It is not possible to use a single invocation of p4 filelog to get
revision data for all changelists returned by p4 annotate.  To prevent
invoking p4 filelog twice (once with -h and once without), retrieve
data for each changelist number individually.

To improve performance, changelists are stored in a map for later reuse.
Move P4JavaException to unchecked conversion to outer try block,
allowing us to remove the inner try block and reduce complexity.  The
location of this conversion doesn't matter.

Iterate file annotations only once.

Add additional line annotation in test.  Ensure server.getChangelist is
invoked once to verify storing/retrieval from changelistMap works as
intended.

Add test for blame on last empty line.
@henryju henryju force-pushed the feature/ignore_unsubmitted_files branch from 94a528c to e96ca3c Compare January 6, 2016 14:32
@henryju henryju merged commit e96ca3c into master Jan 6, 2016
@henryju henryju deleted the feature/ignore_unsubmitted_files branch January 6, 2016 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants