Display the size of a patch (lines added/removed)

In a patch table we now display the number of new lines added or the
number of lines deleted for each file, assuming it is not binary.
Added files only show the total number of lines, while deleted
files show nothing at all.

A new row is added at the bottom of the table that shows the overall
size of the delta.  This can be useful if a project has rules about
how big a patch can be before additional types of review are required
(e.g. Eclipse based projects).

Bug: issue 499
Change-Id: I961d8fac3f5d82a5d24f0a4d0b0a9ddf39182a50
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-08-21 19:04:56 -07:00
parent b6adfc74c3
commit d4b2787ed3
13 changed files with 169 additions and 8 deletions

View File

@@ -194,6 +194,12 @@ public final class Patch {
/** Number of drafts by the current user; not persisted in the datastore. */
protected int nbrDrafts;
/** Number of lines added to the file. */
protected int insertions;
/** Number of lines deleted from the file. */
protected int deletions;
/**
* Original if {@link #changeType} is {@link ChangeType#COPIED} or
* {@link ChangeType#RENAMED}.
@@ -232,6 +238,22 @@ public final class Patch {
nbrDrafts = n;
}
public int getInsertions() {
return insertions;
}
public void setInsertions(int n) {
insertions = n;
}
public int getDeletions() {
return deletions;
}
public void setDeletions(int n) {
deletions = n;
}
public ChangeType getChangeType() {
return ChangeType.forCode(changeType);
}