Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/HgInternals.java @ 300:650b45d290b1
Share range check code
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 17 Sep 2011 13:41:04 +0200 |
parents | 02f2963c70fa |
children | a37ce7145c3f |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgInternals.java Sat Sep 17 13:26:52 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgInternals.java Sat Sep 17 13:41:04 2011 +0200 @@ -152,4 +152,17 @@ public static boolean wrongLocalRevision(int rev) { return rev < 0 && rev != TIP && rev != WORKING_COPY && rev != BAD_REVISION; } + + // throws IllegalArgumentException if [start..end] range is not a subrange of [0..lastRevision] + public static void checkRevlogRange(int start, int end, int lastRevision) { + if (start < 0 || start > lastRevision) { + throw new IllegalArgumentException(String.format("Bad left range boundary %d in [0..%d]", start, lastRevision)); + } + if (end < 0 || end > lastRevision) { + throw new IllegalArgumentException(String.format("Bad right range boundary %d in [0..%d]", end, lastRevision)); + } + if (end < start) { + throw new IllegalArgumentException(String.format("Bad range [%d..%d]", start, end)); + } + } }