diff src/com/tmate/hgkit/console/Status.java @ 18:02ee376bee79

status operation against current working directory
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 03 Jan 2011 20:42:52 +0100
parents 382cfe9463db
children 11cfabe692b3
line wrap: on
line diff
--- a/src/com/tmate/hgkit/console/Status.java	Mon Dec 27 01:43:08 2010 +0100
+++ b/src/com/tmate/hgkit/console/Status.java	Mon Jan 03 20:42:52 2011 +0100
@@ -3,6 +3,8 @@
  */
 package com.tmate.hgkit.console;
 
+import static com.tmate.hgkit.ll.HgRepository.TIP;
+
 import com.tmate.hgkit.fs.RepositoryLookup;
 import com.tmate.hgkit.ll.HgRepository;
 import com.tmate.hgkit.ll.LocalHgRepo;
@@ -23,5 +25,64 @@
 		}
 		System.out.println(hgRepo.getLocation());
 		((LocalHgRepo) hgRepo).loadDirstate().dump();
+		//hgRepo.status(TIP, TIP, new StatusDump());
+		final StatusDump dump = new StatusDump();
+		dump.showIgnored = false;
+		dump.showClean = false;
+		((LocalHgRepo) hgRepo).statusLocal(TIP, dump);
+	}
+
+	private static class StatusDump implements HgRepository.StatusInspector {
+		public boolean hideStatusPrefix = false; // hg status -n option
+		public boolean showCopied = true; // -C
+		public boolean showIgnored = true; // -i
+		public boolean showClean = true; // -c
+
+		public void modified(String fname) {
+			print('M', fname);
+		}
+
+		public void added(String fname) {
+			print('A', fname);
+		}
+
+		public void copied(String fnameOrigin, String fnameAdded) {
+			added(fnameAdded);
+			if (showCopied) {
+				print(' ', fnameOrigin);
+			}
+		}
+
+		public void removed(String fname) {
+			print('R', fname);
+		}
+
+		public void clean(String fname) {
+			if (showClean) {
+				print('C', fname);
+			}
+		}
+
+		public void missing(String fname) {
+			print('!', fname);
+		}
+
+		public void unknown(String fname) {
+			print('?', fname);
+		}
+
+		public void ignored(String fname) {
+			if (showIgnored) {
+				print('I', fname);
+			}
+		}
+		
+		private void print(char status, String fname) {
+			if (!hideStatusPrefix) {
+				System.out.print(status);
+				System.out.print(' ');
+			}
+			System.out.println(fname);
+		}
 	}
 }