Mercurial > hg4j
changeset 362:4937e35b805b
Report dirstate access error with Exception
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 09 Dec 2011 01:14:41 +0100 |
parents | 8099939af5fa |
children | d9dfa9fe9cec |
files | cmdline/org/tmatesoft/hg/console/Main.java src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java |
diffstat | 2 files changed, 22 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java Fri Dec 09 01:13:53 2011 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Main.java Fri Dec 09 01:14:41 2011 +0100 @@ -334,10 +334,10 @@ cmd.execute(sink); System.out.println(sink.toArray().length); HgFileInformer i = new HgFileInformer(hgRepo); - boolean result = i.changeset(cset).check(file); + boolean result = i.changeset(cset).checkExists(file); Assert.assertFalse(result); Assert.assertFalse(i.exists()); - result = i.followRenames(true).check(file); + result = i.followRenames(true).checkExists(file); Assert.assertTrue(result); Assert.assertTrue(i.exists()); HgCatCommand cmd2 = new HgCatCommand(hgRepo).revision(i.getFileRevision()); @@ -367,7 +367,7 @@ return String.format("%s %s (%d bytes)", r.getPath(), r.getRevision(), sink.toArray().length); } - private void testFileStatus() throws IOException { + private void testFileStatus() throws HgException, IOException { // final Path path = Path.create("src/org/tmatesoft/hg/util/"); // final Path path = Path.create("src/org/tmatesoft/hg/internal/Experimental.java"); // final Path path = Path.create("missing-dir/");
--- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java Fri Dec 09 01:13:53 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java Fri Dec 09 01:14:41 2011 +0100 @@ -65,14 +65,23 @@ private PathPool pathPool; private ManifestRevision dirstateParentManifest; + /** + * Collector that iterates over complete working copy + */ public HgWorkingCopyStatusCollector(HgRepository hgRepo) { this(hgRepo, new HgInternals(hgRepo).createWorkingDirWalker(null)); } - // FIXME document cons - public HgWorkingCopyStatusCollector(HgRepository hgRepo, FileIterator hgRepoWalker) { + /** + * Collector may analyze and report status for any arbitrary sub-tree of the working copy. + * File iterator shall return names of the files relative to the repository root. + * + * @param hgRepo status target repository + * @param workingCopyWalker iterator over files in the working copy + */ + public HgWorkingCopyStatusCollector(HgRepository hgRepo, FileIterator workingCopyWalker) { repo = hgRepo; - repoWalker = hgRepoWalker; + repoWalker = workingCopyWalker; } /** @@ -143,23 +152,15 @@ // may be invoked few times, TIP or WORKING_COPY indicate comparison shall be run against working copy parent // NOTE, use of TIP constant requires certain care. TIP here doesn't mean latest cset, but actual working copy parent. - public void walk(int baseRevision, HgStatusInspector inspector) throws IOException { + public void walk(int baseRevision, HgStatusInspector inspector) throws HgInvalidControlFileException, IOException { if (HgInternals.wrongLocalRevision(baseRevision) || baseRevision == BAD_REVISION) { throw new IllegalArgumentException(String.valueOf(baseRevision)); } - try { - if (getDirstateImpl() == null) { - // FIXME this is a hack to avoid declaring throws for the #walk() at the moment - // once I decide whether to have mediator that collects errors or to use exceptions here - // this hack shall be removed in favor of either severe error in mediator or a re-thrown exception. - getDirstate(); - } - if (getDirstateParentManifest() == null) { - initDirstateParentManifest(); - } - } catch (HgInvalidControlFileException ex) { - repo.getContext().getLog().error(getClass(), ex, "Failed to initialize with dirstate information"); - return; + if (getDirstateImpl() == null) { + getDirstate(); + } + if (getDirstateParentManifest() == null) { + initDirstateParentManifest(); } ManifestRevision collect = null; // non null indicates we compare against base revision Set<Path> baseRevFiles = Collections.emptySet(); // files from base revision not affected by status calculation @@ -271,7 +272,7 @@ } } - public HgStatusCollector.Record status(int baseRevision) throws IOException { + public HgStatusCollector.Record status(int baseRevision) throws HgInvalidControlFileException, IOException { HgStatusCollector.Record rv = new HgStatusCollector.Record(); walk(baseRevision, rv); return rv;