Merge "Add lines count parameter to the inlineComments function."

This commit is contained in:
Shawn Pearce
2012-06-05 22:05:38 -07:00
committed by gerrit code review
3 changed files with 69 additions and 8 deletions

View File

@@ -111,6 +111,35 @@ public class PatchFile {
}
}
/**
* Return number of lines in file.
*
* @param file the file index to extract.
* @return number of lines in file.
* @throws CorruptEntityException the patch cannot be read.
* @throws IOException the patch or complete file content cannot be read.
* @throws NoSuchEntityException the file is not exist.
*/
public int getLineCount(final int file)
throws CorruptEntityException, IOException, NoSuchEntityException {
switch (file) {
case 0:
if (a == null) {
a = load(aTree, entry.getOldName());
}
return a.size();
case 1:
if (b == null) {
b = load(bTree, entry.getNewName());
}
return b.size();
default:
throw new NoSuchEntityException();
}
}
private Text load(final ObjectId tree, final String path)
throws MissingObjectException, IncorrectObjectTypeException,
CorruptObjectException, IOException {