Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgDataFile.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 | b3c16d1aede0 |
comparison
equal
deleted
inserted
replaced
| 454:36fd1fd06492 | 456:909306e412e2 |
|---|---|
| 16 */ | 16 */ |
| 17 package org.tmatesoft.hg.repo; | 17 package org.tmatesoft.hg.repo; |
| 18 | 18 |
| 19 import static org.tmatesoft.hg.repo.HgInternals.wrongRevisionIndex; | 19 import static org.tmatesoft.hg.repo.HgInternals.wrongRevisionIndex; |
| 20 import static org.tmatesoft.hg.repo.HgRepository.*; | 20 import static org.tmatesoft.hg.repo.HgRepository.*; |
| 21 import static org.tmatesoft.hg.util.LogFacility.Severity.*; | |
| 21 | 22 |
| 22 import java.io.ByteArrayOutputStream; | 23 import java.io.ByteArrayOutputStream; |
| 23 import java.io.File; | 24 import java.io.File; |
| 24 import java.io.FileInputStream; | 25 import java.io.FileInputStream; |
| 25 import java.io.IOException; | 26 import java.io.IOException; |
| 179 progress.done(); | 180 progress.done(); |
| 180 if (fc != null) { | 181 if (fc != null) { |
| 181 try { | 182 try { |
| 182 fc.close(); | 183 fc.close(); |
| 183 } catch (IOException ex) { | 184 } catch (IOException ex) { |
| 184 getRepo().getContext().getLog().info(getClass(), ex, null); | 185 getRepo().getContext().getLog().dump(getClass(), Warn, ex, null); |
| 185 } | 186 } |
| 186 } | 187 } |
| 187 } | 188 } |
| 188 } else { | 189 } else { |
| 189 Nodeid fileRev = getWorkingCopyRevision(); | 190 Nodeid fileRev = getWorkingCopyRevision(); |
| 205 Nodeid p = wcParents.first().isNull() ? wcParents.second() : wcParents.first(); | 206 Nodeid p = wcParents.first().isNull() ? wcParents.second() : wcParents.first(); |
| 206 final HgChangelog clog = getRepo().getChangelog(); | 207 final HgChangelog clog = getRepo().getChangelog(); |
| 207 final int csetRevIndex; | 208 final int csetRevIndex; |
| 208 if (p.isNull()) { | 209 if (p.isNull()) { |
| 209 // no dirstate parents | 210 // no dirstate parents |
| 210 getRepo().getContext().getLog().info(getClass(), "No dirstate parents, resort to TIP", getPath()); | 211 getRepo().getContext().getLog().dump(getClass(), Info, "No dirstate parents, resort to TIP", getPath()); |
| 211 // if it's a repository with no dirstate, use TIP then | 212 // if it's a repository with no dirstate, use TIP then |
| 212 csetRevIndex = clog.getLastRevision(); | 213 csetRevIndex = clog.getLastRevision(); |
| 213 if (csetRevIndex == -1) { | 214 if (csetRevIndex == -1) { |
| 214 // shall not happen provided there's .i for this data file (hence at least one cset) | 215 // shall not happen provided there's .i for this data file (hence at least one cset) |
| 215 // and perhaps exception is better here. However, null as "can't find" indication seems reasonable. | 216 // and perhaps exception is better here. However, null as "can't find" indication seems reasonable. |
| 605 // XXX is it possible to have here incomplete key/value (i.e. if last pair didn't end with \n) | 606 // XXX is it possible to have here incomplete key/value (i.e. if last pair didn't end with \n) |
| 606 // if yes, need to set metadataIsComplete to true in that case as well | 607 // if yes, need to set metadataIsComplete to true in that case as well |
| 607 break; | 608 break; |
| 608 } | 609 } |
| 609 if (key == null || lastColon == -1 || i <= lastColon) { | 610 if (key == null || lastColon == -1 || i <= lastColon) { |
| 610 log.error(getClass(), "Missing key in file revision metadata at index %d", i); | 611 log.dump(getClass(), Error, "Missing key in file revision metadata at index %d", i); |
| 611 } | 612 } |
| 612 value = new String(bos.toByteArray()).trim(); | 613 value = new String(bos.toByteArray()).trim(); |
| 613 bos.reset(); | 614 bos.reset(); |
| 614 _metadata.add(new MetadataEntry(key, value)); | 615 _metadata.add(new MetadataEntry(key, value)); |
| 615 key = value = null; | 616 key = value = null; |
