diff options
author | Shawn O. Pearce <sop@google.com> | 2008-12-12 15:47:55 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2008-12-12 15:47:55 -0800 |
commit | 403fec416ad264233d87c214765a6e89fdb34763 (patch) | |
tree | ef45cbc3491f8793fe31485397c0f1505efdcff7 /webapp | |
parent | 43a6d6e4a908ace12caf8c919395cb66ee316888 (diff) |
Add patch type and source file name to Patch entity
We need these in order to quickly determine what the patch
for this entity looks like, so we can produce the right
style of hyperlinks on its row.
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/src/com/google/gerrit/client/reviewdb/Patch.java | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/webapp/src/com/google/gerrit/client/reviewdb/Patch.java b/webapp/src/com/google/gerrit/client/reviewdb/Patch.java index 731376b877..7012f54c26 100644 --- a/webapp/src/com/google/gerrit/client/reviewdb/Patch.java +++ b/webapp/src/com/google/gerrit/client/reviewdb/Patch.java @@ -51,7 +51,11 @@ public final class Patch { MODIFIED('M'), - DELETED('D'); + DELETED('D'), + + RENAMED('R'), + + COPIED('C'); private final char code; @@ -73,6 +77,33 @@ public final class Patch { } } + public static enum PatchType { + UNIFIED('U'), + + BINARY('B'), + + N_WAY('N'); + + private final char code; + + private PatchType(final char c) { + code = c; + } + + public char getCode() { + return code; + } + + public static PatchType forCode(final char c) { + for (final PatchType s : PatchType.values()) { + if (s.code == c) { + return s; + } + } + return null; + } + } + @Column(name = Column.NONE) protected Id key; @@ -80,16 +111,28 @@ public final class Patch { @Column protected char changeType; + /** What type of patch is this; see {@link PatchType}. */ + @Column + protected char patchType; + /** Number of published comments on this patch. */ @Column protected int nbrComments; + /** + * Original if {@link #changeType} is {@link ChangeType#COPIED} or + * {@link ChangeType#RENAMED}. + */ + @Column(notNull = false) + protected String sourceFileName; + protected Patch() { } - public Patch(final Patch.Id newId, final ChangeType type) { + public Patch(final Patch.Id newId, final ChangeType ct, final PatchType pt) { key = newId; - setChangeType(type); + setChangeType(ct); + setPatchType(pt); } public Patch.Id getKey() { @@ -107,4 +150,24 @@ public final class Patch { public void setChangeType(final ChangeType type) { changeType = type.getCode(); } + + public PatchType getPatchType() { + return PatchType.forCode(patchType); + } + + public void setPatchType(final PatchType type) { + patchType = type.getCode(); + } + + public String getFileName() { + return key.fileName; + } + + public String getSourceFileName() { + return sourceFileName; + } + + public void setSourceFileName(final String n) { + sourceFileName = n; + } } |