Merge branch 'stable-2.15' into stable-2.16
* stable-2.15: PatchFile: Fix getting comment context for left side Revert "Allow load labels to cross package boundaries by default" CommentSender: Add line number in debug log Change-Id: I7cc5200a389bd4ff62a399537e74bb753e733be2
This commit is contained in:
1
.bazelrc
1
.bazelrc
@@ -4,7 +4,6 @@ build --experimental_strict_action_env
|
||||
build --action_env=PATH
|
||||
build --disk_cache=~/.gerritcodereview/bazel-cache/cas
|
||||
build --java_toolchain //tools:error_prone_warnings_toolchain
|
||||
build --incompatible_disallow_load_labels_to_cross_package_boundaries=false
|
||||
|
||||
test --build_tests_only
|
||||
test --test_output=errors
|
||||
|
||||
@@ -535,7 +535,8 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
} catch (IndexOutOfBoundsException err) {
|
||||
// Default to the empty string if the given line number does not appear
|
||||
// in the file.
|
||||
logger.atFine().withCause(err).log("Failed to get line number of file on side %d", side);
|
||||
logger.atFine().withCause(err).log(
|
||||
"Failed to get line number %d of file on side %d", lineNbr, side);
|
||||
return "";
|
||||
} catch (NoSuchEntityException err) {
|
||||
// Default to the empty string if the side cannot be found.
|
||||
|
||||
@@ -87,6 +87,14 @@ public class PatchFile {
|
||||
}
|
||||
}
|
||||
|
||||
private String getOldName() {
|
||||
String name = entry.getOldName();
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
return entry.getNewName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a line from the file, as a string.
|
||||
*
|
||||
@@ -100,7 +108,7 @@ public class PatchFile {
|
||||
switch (file) {
|
||||
case 0:
|
||||
if (a == null) {
|
||||
a = load(aTree, entry.getOldName());
|
||||
a = load(aTree, getOldName());
|
||||
}
|
||||
return a.getString(line - 1);
|
||||
|
||||
@@ -127,7 +135,7 @@ public class PatchFile {
|
||||
switch (file) {
|
||||
case 0:
|
||||
if (a == null) {
|
||||
a = load(aTree, entry.getOldName());
|
||||
a = load(aTree, getOldName());
|
||||
}
|
||||
return a.size();
|
||||
|
||||
|
||||
@@ -532,6 +532,13 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void publishCommentsAllRevisions() throws Exception {
|
||||
PushOneCommit.Result result = createChange();
|
||||
String changeId = result.getChangeId();
|
||||
|
||||
pushFactory
|
||||
.create(db, admin.getIdent(), testRepo, SUBJECT, FILE_NAME, "initial content\n", changeId)
|
||||
.to("refs/heads/master");
|
||||
|
||||
PushOneCommit.Result r1 =
|
||||
pushFactory
|
||||
.create(db, admin.getIdent(), testRepo, SUBJECT, FILE_NAME, "old boring content\n")
|
||||
@@ -556,7 +563,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
addDraft(
|
||||
r1.getChangeId(),
|
||||
r1.getCommit().getName(),
|
||||
newDraft(FILE_NAME, Side.PARENT, 2, "what happened to this?"));
|
||||
newDraft(FILE_NAME, Side.PARENT, createLineRange(1, 0, 7), "what happened to this?"));
|
||||
addDraft(
|
||||
r2.getChangeId(),
|
||||
r2.getCommit().getName(),
|
||||
@@ -641,8 +648,8 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
+ project.get()
|
||||
+ "/+/"
|
||||
+ c
|
||||
+ "/1/a.txt@a2 \n"
|
||||
+ "PS1, Line 2: \n"
|
||||
+ "/1/a.txt@a1 \n"
|
||||
+ "PS1, Line 1: initial\n"
|
||||
+ "what happened to this?\n"
|
||||
+ "\n"
|
||||
+ "\n"
|
||||
@@ -670,7 +677,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
+ "/+/"
|
||||
+ c
|
||||
+ "/2/a.txt@a1 \n"
|
||||
+ "PS2, Line 1: \n"
|
||||
+ "PS2, Line 1: initial content\n"
|
||||
+ "comment 1 on base\n"
|
||||
+ "\n"
|
||||
+ "\n"
|
||||
@@ -700,7 +707,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
+ "/+/"
|
||||
+ c
|
||||
+ "/2/a.txt@2 \n"
|
||||
+ "PS2, Line 2: nten\n"
|
||||
+ "PS2, Line 2: cntent\n"
|
||||
+ "typo: content\n"
|
||||
+ "\n"
|
||||
+ "\n");
|
||||
@@ -1135,7 +1142,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
|
||||
private DraftInput newDraft(String path, Side side, Comment.Range range, String message) {
|
||||
DraftInput d = new DraftInput();
|
||||
return populate(d, path, side, null, range, message, false);
|
||||
return populate(d, path, side, null, range.startLine, range, message, false);
|
||||
}
|
||||
|
||||
private DraftInput newDraftOnParent(String path, int parent, int line, String message) {
|
||||
@@ -1148,23 +1155,25 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
String path,
|
||||
Side side,
|
||||
Integer parent,
|
||||
int line,
|
||||
Comment.Range range,
|
||||
String message,
|
||||
Boolean unresolved) {
|
||||
int line = range.startLine;
|
||||
c.path = path;
|
||||
c.side = side;
|
||||
c.parent = parent;
|
||||
c.line = line != 0 ? line : null;
|
||||
c.message = message;
|
||||
c.unresolved = unresolved;
|
||||
if (line != 0) c.range = range;
|
||||
if (range != null) {
|
||||
c.range = range;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
private static <C extends Comment> C populate(
|
||||
C c, String path, Side side, Integer parent, int line, String message, Boolean unresolved) {
|
||||
return populate(c, path, side, parent, createLineRange(line, 1, 5), message, unresolved);
|
||||
return populate(c, path, side, parent, line, null, message, unresolved);
|
||||
}
|
||||
|
||||
private static Comment.Range createLineRange(int line, int startChar, int endChar) {
|
||||
|
||||
Reference in New Issue
Block a user