changeset 429:cd658b24a620

FIXMEs: javadoc, proper use of constants
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 29 Mar 2012 18:29:03 +0200
parents ead6c67f3319
children d280759c2a3f
files cmdline/org/tmatesoft/hg/console/Main.java src/org/tmatesoft/hg/core/HgStatusCommand.java src/org/tmatesoft/hg/repo/HgStatusInspector.java src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java src/org/tmatesoft/hg/util/RegularFileStats.java test/org/tmatesoft/hg/test/TestStatus.java
diffstat 6 files changed, 27 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java	Thu Mar 29 18:05:05 2012 +0200
+++ b/cmdline/org/tmatesoft/hg/console/Main.java	Thu Mar 29 18:29:03 2012 +0200
@@ -17,6 +17,7 @@
 package org.tmatesoft.hg.console;
 
 import static org.tmatesoft.hg.repo.HgRepository.TIP;
+import static org.tmatesoft.hg.repo.HgRepository.WORKING_COPY;
 
 import java.io.File;
 import java.io.IOException;
@@ -434,7 +435,7 @@
 //		final Path path = Path.create("missing-dir/");
 //		HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, path);
 		HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("mi**"));
-		wcsc.walk(TIP, new StatusDump());
+		wcsc.walk(WORKING_COPY, new StatusDump());
 	}
 	
 	/*
@@ -600,7 +601,7 @@
 		sc.change(0, dump);
 		System.out.println("\nStatus against working dir:");
 		HgWorkingCopyStatusCollector wcc = new HgWorkingCopyStatusCollector(hgRepo);
-		wcc.walk(TIP, dump);
+		wcc.walk(WORKING_COPY, dump);
 		System.out.println();
 		System.out.printf("Manifest of the revision %d:\n", r2);
 		hgRepo.getManifest().walk(r2, r2, new ManifestDump());
--- a/src/org/tmatesoft/hg/core/HgStatusCommand.java	Thu Mar 29 18:05:05 2012 +0200
+++ b/src/org/tmatesoft/hg/core/HgStatusCommand.java	Thu Mar 29 18:29:03 2012 +0200
@@ -165,12 +165,12 @@
 	 * @param statusHandler callback to get status information
  	 * @throws HgCallbackTargetException propagated exception from the handler
 	 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state
+	 * @throws IOException if there are (further unspecified) errors while walking working copy
 	 * @throws CancelledException if execution of the command was cancelled
-	 * @throws IOException FIXME EXCEPTIONS WTF it's doing here if there are (further unspecified) errors while walking working copy
 	 * @throws IllegalArgumentException if handler is <code>null</code>
 	 * @throws ConcurrentModificationException if this command already runs (i.e. being used from another thread)
 	 */
-	public void execute(HgStatusHandler statusHandler) throws HgCallbackTargetException, HgException, CancelledException, IOException {
+	public void execute(HgStatusHandler statusHandler) throws HgCallbackTargetException, HgException, IOException, CancelledException {
 		if (statusHandler == null) {
 			throw new IllegalArgumentException();
 		}
--- a/src/org/tmatesoft/hg/repo/HgStatusInspector.java	Thu Mar 29 18:05:05 2012 +0200
+++ b/src/org/tmatesoft/hg/repo/HgStatusInspector.java	Thu Mar 29 18:29:03 2012 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2011 TMate Software Ltd
+ * Copyright (c) 2010-2012 TMate Software Ltd
  *  
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
  */
 package org.tmatesoft.hg.repo;
 
+import org.tmatesoft.hg.internal.Callback;
 import org.tmatesoft.hg.util.Path;
 
 /**
@@ -24,6 +25,7 @@
  * @author Artem Tikhomirov
  * @author TMate Software Ltd.
  */
+@Callback
 public interface HgStatusInspector {
 	void modified(Path fname);
 	void added(Path fname);
--- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Thu Mar 29 18:05:05 2012 +0200
+++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Thu Mar 29 18:29:03 2012 +0200
@@ -151,11 +151,16 @@
 	}
 	
 	/**
-	 * may be invoked few times, TIP or WORKING_COPY indicate comparison shall be run against working copy parent
-	 * XXX NOTE, use of TIP constant requires certain care. TIP here doesn't mean latest cset, but actual working copy parent.
+	 * Walk working copy, analyze status for each file found and missing.
+	 * May be invoked few times.
 	 * 
-	 * @param baseRevision
-	 * @param inspector
+	 * <p>There's no dedicated constant to for working copy parent, at least now. 
+	 * Use {@link HgRepository#WORKING_COPY} to indicate comparison 
+	 * shall be run against working copy parent. Although a bit confusing, single case doesn't 
+	 * justify a dedicated constant.
+	 * 
+	 * @param baseRevision revision index to check against, or {@link HgRepository#WORKING_COPY}. Note, {@link HgRepository#TIP} is not supported.
+	 * @param inspector callback to receive status information
 	 * @throws IOException to propagate IO errors from {@link FileIterator}
 	 * @throws CancelledException if operation execution was cancelled
 	 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
@@ -170,6 +175,7 @@
 		if (getDirstateParentManifest() == null) {
 			initDirstateParentManifest();
 		}
+		// XXX NOTE, use of TIP for working copy parent is questionable, at least. Instead, TIP shall mean latest cset or not allowed at all
 		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 
 		if (baseRevision != TIP && baseRevision != WORKING_COPY) {
@@ -285,11 +291,12 @@
 	}
 
 	/**
+	 * A {@link #walk(int, HgStatusInspector)} that records all the status information in the {@link HgStatusCollector.Record} object.
 	 * 
-	 * @param baseRevision
+	 * @see #walk(int, HgStatusInspector)
+	 * @param baseRevision revision index to check against, or {@link HgRepository#WORKING_COPY}. Note, {@link HgRepository#TIP} is not supported.
 	 * @return information object that describes change between the revisions
 	 * @throws IOException to propagate IO errors from {@link FileIterator}
-	 * @throws CancelledException if operation execution was cancelled
 	 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
 	 */
 	public HgStatusCollector.Record status(int baseRevision) throws IOException, HgRuntimeException {
--- a/src/org/tmatesoft/hg/util/RegularFileStats.java	Thu Mar 29 18:05:05 2012 +0200
+++ b/src/org/tmatesoft/hg/util/RegularFileStats.java	Thu Mar 29 18:29:03 2012 +0200
@@ -102,7 +102,7 @@
 		// can't check isFile because Java would say false for a symlink with non-existing target
 		if (f.isDirectory()) {
 			// perhaps, shall just collect stats for all files and set false to exec/link flags?
-			throw new IllegalArgumentException(); // FIXME EXCEPTIONS
+			throw new IllegalArgumentException();
 		}
 		final String dirName = f.getParentFile().getAbsolutePath();
 		final String fileName = f.getName();
--- a/test/org/tmatesoft/hg/test/TestStatus.java	Thu Mar 29 18:05:05 2012 +0200
+++ b/test/org/tmatesoft/hg/test/TestStatus.java	Thu Mar 29 18:29:03 2012 +0200
@@ -21,6 +21,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.tmatesoft.hg.core.HgStatus.Kind.*;
 import static org.tmatesoft.hg.repo.HgRepository.TIP;
+import static org.tmatesoft.hg.repo.HgRepository.WORKING_COPY;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -382,7 +383,7 @@
 		final Path file3 = Path.create("dir/file3");
 		HgWorkingCopyStatusCollector sc = HgWorkingCopyStatusCollector.create(repo, file2, file3);
 		HgStatusCollector.Record r = new HgStatusCollector.Record();
-		sc.walk(TIP, r);
+		sc.walk(WORKING_COPY, r);
 		assertTrue(r.getAdded().isEmpty());
 		assertTrue(r.getRemoved().isEmpty());
 		assertTrue(r.getUnknown().isEmpty());
@@ -397,7 +398,7 @@
 		final Path readme = Path.create("readme");
 		final Path dir = Path.create("dir/");
 		sc = HgWorkingCopyStatusCollector.create(repo, readme, dir);
-		sc.walk(TIP, r = new HgStatusCollector.Record());
+		sc.walk(WORKING_COPY, r = new HgStatusCollector.Record());
 		assertTrue(r.getAdded().isEmpty());
 		assertTrue(r.getRemoved().size() == 2);
 		for (Path p : r.getRemoved()) {
@@ -421,13 +422,13 @@
 		
 		HgWorkingCopyStatusCollector sc = HgWorkingCopyStatusCollector.create(repo, file3, file5);
 		HgStatusCollector.Record r;
-		sc.walk(TIP, r = new HgStatusCollector.Record());
+		sc.walk(WORKING_COPY, r = new HgStatusCollector.Record());
 		assertTrue(r.getRemoved().contains(file5));
 		assertTrue(r.getIgnored().contains(file3));
 		//
 		// query for the same file, but with
 		sc = HgWorkingCopyStatusCollector.create(repo, new PathGlobMatcher(file3.toString(), file5.toString()));
-		sc.walk(TIP, r = new HgStatusCollector.Record());
+		sc.walk(WORKING_COPY, r = new HgStatusCollector.Record());
 		assertTrue(r.getRemoved().contains(file5));
 		assertTrue(r.getIgnored().contains(file3));
 	}