Mercurial > hg4j
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 299:45dc79e545f5 | 300:650b45d290b1 |
|---|---|
| 150 | 150 |
| 151 // Convenient check of local revision number for validity (not all negative values are wrong as long as we use negative constants) | 151 // Convenient check of local revision number for validity (not all negative values are wrong as long as we use negative constants) |
| 152 public static boolean wrongLocalRevision(int rev) { | 152 public static boolean wrongLocalRevision(int rev) { |
| 153 return rev < 0 && rev != TIP && rev != WORKING_COPY && rev != BAD_REVISION; | 153 return rev < 0 && rev != TIP && rev != WORKING_COPY && rev != BAD_REVISION; |
| 154 } | 154 } |
| 155 | |
| 156 // throws IllegalArgumentException if [start..end] range is not a subrange of [0..lastRevision] | |
| 157 public static void checkRevlogRange(int start, int end, int lastRevision) { | |
| 158 if (start < 0 || start > lastRevision) { | |
| 159 throw new IllegalArgumentException(String.format("Bad left range boundary %d in [0..%d]", start, lastRevision)); | |
| 160 } | |
| 161 if (end < 0 || end > lastRevision) { | |
| 162 throw new IllegalArgumentException(String.format("Bad right range boundary %d in [0..%d]", end, lastRevision)); | |
| 163 } | |
| 164 if (end < start) { | |
| 165 throw new IllegalArgumentException(String.format("Bad range [%d..%d]", start, end)); | |
| 166 } | |
| 167 } | |
| 155 } | 168 } |
