Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/Revlog.java @ 456:909306e412e2
Refactor LogFacility and SessionContext, better API for both
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 18 Jun 2012 16:54:00 +0200 |
parents | 32184ddcf46d |
children | 7bcfbc255f48 |
comparison
equal
deleted
inserted
replaced
454:36fd1fd06492 | 456:909306e412e2 |
---|---|
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.repo; | 17 package org.tmatesoft.hg.repo; |
18 | 18 |
19 import static org.tmatesoft.hg.repo.HgRepository.*; | 19 import static org.tmatesoft.hg.repo.HgRepository.*; |
20 import static org.tmatesoft.hg.util.LogFacility.Severity.Warn; | |
20 | 21 |
21 import java.io.IOException; | 22 import java.io.IOException; |
22 import java.nio.ByteBuffer; | 23 import java.nio.ByteBuffer; |
23 import java.util.ArrayList; | 24 import java.util.ArrayList; |
24 import java.util.Arrays; | 25 import java.util.Arrays; |
430 buf.flip(); // post: position == 0 | 431 buf.flip(); // post: position == 0 |
431 // XXX I may not rely on returned number of bytes but track change in buf position instead. | 432 // XXX I may not rely on returned number of bytes but track change in buf position instead. |
432 | 433 |
433 int consumed = sink.write(buf); | 434 int consumed = sink.write(buf); |
434 if ((consumed == 0 || consumed != buf.position()) && logFacility != null) { | 435 if ((consumed == 0 || consumed != buf.position()) && logFacility != null) { |
435 logFacility.warn(getClass(), "Bad data sink when reading revision %d. Reported %d bytes consumed, byt actually read %d", revisionNumber, consumed, buf.position()); | 436 logFacility.dump(getClass(), Warn, "Bad data sink when reading revision %d. Reported %d bytes consumed, byt actually read %d", revisionNumber, consumed, buf.position()); |
436 } | 437 } |
437 if (buf.position() == 0) { | 438 if (buf.position() == 0) { |
438 throw new HgInvalidStateException("Bad sink implementation (consumes no bytes) results in endless loop"); | 439 throw new HgInvalidStateException("Bad sink implementation (consumes no bytes) results in endless loop"); |
439 } | 440 } |
440 buf.compact(); // ensure (a) there's space for new (b) data starts at 0 | 441 buf.compact(); // ensure (a) there's space for new (b) data starts at 0 |