diff options
author | Gustaf Lundh <gustaf.lundh@sonymobile.com> | 2012-10-05 18:10:12 +0200 |
---|---|---|
committer | Edwin Kempin <edwin.kempin@sap.com> | 2012-10-12 16:52:46 +0200 |
commit | 7c245a6cb7bc7719f74c1c9bd02096cd91c24dfe (patch) | |
tree | 80df5a7492656314819ef85eecff289563ccc7f4 | |
parent | bdc014f90ec30fa2eb58f30674e6f989615ea2f9 (diff) |
File indentation is sometimes wrong in Side-By-Side
To reproduce:
1. Change file indendation in a patch and push.
2. Set "Ignore Whitespace" to "All" in the Prefs.
3. Empty the diff_intraline cache.
4. View the patch using Side-By-Side.
5. Change Ignore Whitespace to "None" and update the
page.
6. The lines with changed indentation are now fetched
from the base, leading gerrit to display the wrong
indentation on the right handed side.
Issue due to diff_intraline cache does not
account for changed whitespace settings, which will
trick SparseFileContent.apply() to grab lines from
left-side hunk when the line is not within the
range of the right sided hunk.
Bug: issue 816
Change-Id: I3b8c8a7aaf5d18696846d757722b3aaa4d04243e
-rw-r--r-- | gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java | 3 | ||||
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/patch/IntraLineDiffKey.java | 14 |
2 files changed, 13 insertions, 4 deletions
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java index ad7746f619..816bbef6eb 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java @@ -147,7 +147,8 @@ class PatchScriptBuilder { } else if (diffPrefs.isIntralineDifference()) { IntraLineDiff d = patchListCache.getIntraLineDiff(new IntraLineDiffKey(a.id, a.src, - b.id, b.src, edits, projectKey, bId, b.path)); + b.id, b.src, edits, projectKey, bId, b.path, + diffPrefs.getIgnoreWhitespace() != Whitespace.IGNORE_NONE)); if (d != null) { switch (d.getStatus()) { case EDIT_LIST: diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/patch/IntraLineDiffKey.java b/gerrit-server/src/main/java/com/google/gerrit/server/patch/IntraLineDiffKey.java index 08af5e72e7..62ed5e4c14 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/patch/IntraLineDiffKey.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/patch/IntraLineDiffKey.java @@ -29,8 +29,9 @@ import java.io.Serializable; import java.util.List; public class IntraLineDiffKey implements Serializable { - static final long serialVersionUID = 3L; + static final long serialVersionUID = 4L; + private transient boolean ignoreWhitespace; private transient ObjectId aId; private transient ObjectId bId; @@ -45,7 +46,8 @@ public class IntraLineDiffKey implements Serializable { private transient String path; public IntraLineDiffKey(ObjectId aId, Text aText, ObjectId bId, Text bText, - List<Edit> edits, Project.NameKey projectKey, ObjectId commit, String path) { + List<Edit> edits, Project.NameKey projectKey, ObjectId commit, String path, + boolean ignoreWhitespace) { this.aId = aId; this.bId = bId; @@ -56,6 +58,8 @@ public class IntraLineDiffKey implements Serializable { this.projectKey = projectKey; this.commit = commit; this.path = path; + + this.ignoreWhitespace = ignoreWhitespace; } Text getTextA() { @@ -96,6 +100,7 @@ public class IntraLineDiffKey implements Serializable { h = h * 31 + aId.hashCode(); h = h * 31 + bId.hashCode(); + h = h * 31 + (ignoreWhitespace ? 1 : 0); return h; } @@ -105,7 +110,8 @@ public class IntraLineDiffKey implements Serializable { if (o instanceof IntraLineDiffKey) { final IntraLineDiffKey k = (IntraLineDiffKey) o; return aId.equals(k.aId) // - && bId.equals(k.bId); + && bId.equals(k.bId) // + && ignoreWhitespace == k.ignoreWhitespace; } return false; } @@ -127,10 +133,12 @@ public class IntraLineDiffKey implements Serializable { private void writeObject(final ObjectOutputStream out) throws IOException { writeNotNull(out, aId); writeNotNull(out, bId); + out.writeBoolean(ignoreWhitespace); } private void readObject(final ObjectInputStream in) throws IOException { aId = readNotNull(in); bId = readNotNull(in); + ignoreWhitespace = in.readBoolean(); } } |